#include<iostream>
using namespace std;
int main() {
string a, b;
int i = 0;
cout << "请输入一串字符" << endl;
if(cin>>a && !a.empty())
while (cin >> b && !b.empty()) {
if (a == b) {
++i;
cout << a << "重复的次数为: " << i << endl;
}
else {
a = b;
i = 0;
cout << "没有出现重复的" << endl;
}
}
return 0;
}
最后修改:2022 年 12 月 05 日
© 允许规范转载
1 条评论
下一道题和这个没太大区别,关键在于需要使用 isupper() 下标这样用 isupper(x[0])