#include <iostream>
#include <string>
using namespace std;
int main()
{
//输入string对象的序列知道相同的单词或者读完
//增加:必须要以大写开头的string对象
string str,last_str;
cout<<"Enter your string :"<<endl;
bool flag=false;
while(cin>>str)
{
if(islower(str[0]))//如果str{0}为小写字母则跳出至12行while
continue;
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;
}
找相同的cin大写开头的string对象
猜你喜欢
转载自blog.csdn.net/zzzfeiyu/article/details/85406269
今日推荐
周排行