解题思路: 输入字符串 - 遍历字符串,数数每个字符出现的次数 - 遍历字符串,输出出现次数为 1 的字符
注意事项:
参考代码:
#include <bits/stdc++.h> using namespace std; int a[10005]; //标记数组 int main() { string str; cin >> str; for(int i = 0; i < str.length(); i ++) a[str[i]] ++; //遍历字符串,给每个字符做标记 for(int i = 0; i < str.length(); i ++) if(a[str[i]] == 1) cout << str[i]; //输出只出现过一次的字符 return 0; }
0.0分
3 人评分
C二级辅导-同因查找 (C语言代码)浏览:581 |
C语言训练-列出最简真分数序列* (C语言代码)浏览:607 |
2003年秋浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:582 |
1017题解浏览:594 |
罗列完美数 (C语言代码)浏览:491 |
C二级辅导-进制转换 (C语言代码)浏览:660 |
数组输出 (C语言代码)浏览:703 |
排序算法(选择,插入,冒泡)浏览:775 |
小O的数字 (C++代码)浏览:759 |
拆分位数 (C语言代码)浏览:441 |