由买买提看人间百态

topics

全部话题 - 话题: currword
(共0页)
y*******i
发帖数: 100
1
来自主题: JobHunting版 - c++ primer求助
读入一系列 string 对象,直到同一
个单词连续出现两次,或者所有的单词都已读完,才结束读取
string preword,currword;
while(cin>>currword){
if(preword==currword){
cout<<"the word is: "< break;
}//end if
else preword=currword;
}//end while
if(currword.empty()||(currword!=preword))
cout<<"there are no adjacent words are the same"< 有重复单词测试成功,但是如果输入一系列没重复单词的单词,总是打印不出"there
are no adjacent words are the same",为什么呢?找了半天找不出逻辑错误。
谢谢各位。
(共0页)