C++primer习题3.21
就是上一个题目的改写,灰常简单:
#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; } } }