#include<iostream>
#include<string>
using namespace std;
char find(char *s){
int hash[256] = { 0 };
char *phashkey = s;
while(*phashkey!='\0'){
hash[*phashkey]++;
phashkey++;
}
phashkey = s;
while (*phashkey != '\0'){
if (hash[*phashkey] == 1)
return *phashkey;
phashkey++;
}
//return '\0';
}
int main(){
int n, m = 0;
char s[256];
cin >> n;
char *b = new char[n];
for (int j = 0; j < n; j++){
cin >> s;
b[m++] = find(s);
}
for (int i = 0; i < m; i++)
cout << b[i] << endl;
system("pause");
return 0;
}
第一个只出现一次的字符(剑指offer 35)360笔试
最新推荐文章于 2017-07-16 15:53:10 发布