总时间限制:
1000ms
内存限制:
65536kB
描述
给定一个只包含小写字母的字符串,请你找到第一个仅出现一次的字符。如果没有,输出no。
输入
一个字符串,长度小于100000。
输出
输出第一个仅出现一次的字符,若没有则输出no。
样例输入
abcabd
样例输出
c
代码:编译环境VS2019
#include<stdio.h>
#include<string.h>
#define MAX 100000
int main()
{
char s[MAX] ; int count=0;
int i, j;
gets(s);
for (i = 0; i < strlen(s); i++) {
for (j = 0; j < strlen(s); j++) {
if (s[i] == s[j]) {
count++;
}
}
if (count == 1) {
printf("%c", s[i]);
return 0;
}
else count = 0;
}
printf("no");
}