C++primer习题3.21

来源:互联网 时间:1970-01-01

就是上一个题目的改写,灰常简单:

#include <iostream>#include<string>using namespace std;int main(){ string cur,pre; bool flag = true; cout << "Please input string: " ; while (cin >> cur ) { if (cur == pre && cur[0] >= 'A' && cur[0] <= 'Z') { cout << "The repeat words are "<<cur <<endl; } else { cout << "Please input string: " ; pre = cur; } } }


相关阅读:
Top