#include <iostream>
#include <string>
using namespace std;
int main(){
string previous;
string current;
while (cin>>current)
{
if(current == previous)
{
cout<< "repeated word: " << previous;
}
previous=current;
}
return 0;
}
所以我输入了一个句子“blah blah foo bar”,但它在blah之后停止,if不满足并且previous被设置为等于current。为什么这不只是用两个变量 = 来阻止它?它怎么知道分析空格之后的下一个单词?