求助:在验证C++Primer第五版中程序时的一些问题,书的15页
按照书上的程序打的,然而运行结果不一样,下面是程序#include <iostream>
int main()
{
int currVal = 0,val = 0;
if (std::cin>>currVal){
int cnt =1;
while (std::cin>>val){
if (val == currVal)
{
++cnt;
}
else {
std::cout<<currVal<<"occurs"
<<cnt<<"times"<<std::endl;
currVal = val;
cnt=1;
}
}
std::cout<<currVal<<"occurs"
<< cnt<<"times"<<std::endl;
}
return 0;
}