#include <iostream>

using namespace std;

int main()
{
      cout << "Please enter words\n";
      string previous =" ";         // 上一個文字,初值為"非文字"
      string current;                  //目前的文字
      while (cin >> current)      //讀取文字流
     {
             if (previous == current)   //檢查文字是否和上一個一樣
                cout << "repeated word: " << current << '\n';
             previous = current;
      }
}

arrow
arrow
    全站熱搜

    凱 發表在 痞客邦 留言(0) 人氣()