华为机试:找出字符串中第一个只出现一次的字符
#include <iostream> #include <algorithm> #include <string> using namespace std; int main() { string str; cin >> str; for (char ch : str) { if (count(str.begin(), str.end(), ch) == 1) { cout << ch << endl; return 0; } } cout << "-1" << endl; return 0; }