您的位置:首页 > 其它

字符串中找出重复出现N次的字符

2014-10-28 21:43 134 查看
/* 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);
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: