第一次只出现一次的字符

来源:互联网 发布:数据备份 方案 编辑:程序博客网 时间:2024/05/19 04:27
#include<iostream>using namespace std;int main(){char str[80];unsigned int table[256] = { 0 };cout << "请输入一个长度不超过80的字符串: " << endl;cin.getline(str, 81, '\n'); char *p = str;while (*p != '\0'){if (table[*p] == 1){cout << "第一次只出现一次的字符是" << *p << endl;break;}p++;}if (*p == '\0')cout << "字符串为空或串中每一个字符都至少出现2次." << endl;return 0;}

0 0
原创粉丝点击