#include <iostream>
#include <string>
using namespace std;
int main()
{
//输入string对象的序列知道相同的单词或者读完
string str,last_str;
cout<<"Enter your string :"<<endl;
bool flag=false;
while(cin>>str)
{
if(str==last_str)
{
flag=true;//用flag判断是因为while结束后str一定等于last—str
break;
}
else
last_str=str;
}
if(flag)
cout<<"the repeat word is : "<<str<<endl;
else
cout<<"No word is repeated!"<<endl;
return 0;
}
输入string对象的序列知道相同的单词
猜你喜欢
转载自blog.csdn.net/zzzfeiyu/article/details/85406224
今日推荐
周排行