Skip to content

Commit

Permalink
Update ex5_21.cpp
Browse files Browse the repository at this point in the history
对于输入 "Hello", "world", "Hello", 输出结果为"Hello occurs twice in succession."。 当处理第二次输入时,由于"world"首字母小写,直接结束这次迭代,tmp的值仍然为"Hello"。 应该在continue结束迭代之前更新tmp的值。
  • Loading branch information
hcqs33 committed Dec 5, 2014
1 parent 2e88684 commit 9fbdbab
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion ch05/ex5_21.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ int main()
{
string read, tmp;
while (cin >> read)
if (!isupper(read[0])) continue;
if (!isupper(read[0]))
{
tmp = read;
continue;
}
else if (read == tmp) break;
else tmp = read;

Expand Down

0 comments on commit 9fbdbab

Please sign in to comment.