任意输入一个字符串,要求去除字符串中的重复字符,只保留一个重复字符 google -->gole i j

#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include <stdlib.h>


int finding(char *P3,int n)//查找的数组的相对位置,
{

   char *q=malloc(100);
   q=P3+n-1;
   int i=1;
  printf("%c\n",*q);
  P3=q+1;
  while(*P3!='\0')
   {
    
    if(*q==*P3)
    {
      return i;
      
    }
    *(P3++);
    i++;
  }
  return 0;
}

char re(char *P3)
{
  int fp=0;
   char *p1=malloc(100); //目的指针
   char *k1=malloc(100); //移动指针
   p1=P3;
  
   int n=1;
   while(*p1!='\0')  
   {
     while(1)
    {
      fp=finding(P3,n);
     
      if(fp==0)
      {
        break;
      }
      if(fp!=0)
      { 
        k1=p1;
        k1+=fp;
        
        while(*k1!='\0')
        {*k1=*(k1+1);
          k1++;
        }
         
      }
    }
    n++;
    p1++;
   }
}
int main()
{
  char *p=malloc(100);
  char *P1=malloc(100);
  int i;
  printf("请你输入字符串\n");
  scanf("%s",P1);
  
  re(P1);
  p=P1;
  while(*p!='\0')
 
  printf("%c",*p++);
 
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值