面接問題:文字列の中で最初の異なるものを見つけて、出力します.

676 ワード



#include
#include
#include
my_find(char *s)
{
int len = 0;
len = strlen(s);
int i = 0;
int j = 0;
int count = 0;
assert(*str != 0);
for (i = 0; i < len; i++)
{
count = 0;
for (j = 0; j < len; j++)
{
if (s[i] == s[j])
count++;
}
 
       if (count = 1)
 return s[i];
}
}
int main()
{
char s[] = "abaccdeff";
int ret = 0;
ret = my_find(s);
printf("%s", ret);
system("pause");
return 0;
}