/* Note:Your choice is C IDE */
#include "string.h"
int flag[100];
void deleteRepeatChar(char *s)
{ int i=0,j,n;
int count[100];
int length=strlen(s);
for(i=0;i<100;i++)
flag[100]=0;
for(i=0;i<length;i++)
{count[i]=0;
for(j=i+1;j<length;j++)
{ if(s[i]==s[j])
{flag[j]=1;
count[i]++;
}
}
}
for(i=0;i<length;i++)
printf("%d",count[i]);
printf("\n");
for(i=0;i<length;i++)
printf("%d",flag[i]);
printf("\n");
for(i=0;i<length;i++)
{if((count[i]==1)&&(flag[i]!=1))
printf("%c",s[i]);
}
}
main()
{
char c[100];
gets(c);
deleteRepeatChar(c);
}
字符串中找出重复出现N次的字符
最新推荐文章于 2025-05-28 14:59:48 发布