废话不多说见代码:
#include <stdio.h>
#include <stdlib.h>
void findSameChar(char* test){
char temp[256]={0};
char *cur=test;
for(;*cur!='\0';cur++){
if(temp[*cur]==1){
printf("%c is a chongfu char\n",*cur);
temp[*cur]++;
}else{
temp[*cur]++;
}
}
}
int main()
{
char test[]="dfdsfsdfdsfsdgreyerthgfjhtrutrjhgjrewrtwe";
findSameChar(test);
return 0;
}
本文提供了一个使用C语言实现的简单程序,该程序能够找出给定字符串中出现重复的字符,并打印出来。通过遍历字符串并利用数组来记录每个字符出现的次数,实现了对重复字符的有效检测。

被折叠的 条评论
为什么被折叠?



