按照書上的一個(gè)例子讀取輸入的數(shù)的次數(shù)出現(xiàn)問題
#include<iostream> using?namespace?std; int?main() { int?cur?=?0,?val?=?0; if?(cin?>>?cur){ int?cnt?=?1; while?(cin?>>?val){ if?(val?==?cur) ++cnt; else?{ cout?<<?cur?<<?"?occurs?" <<?cnt?<<?"?times"?<<?endl; cur?=?val; cnt?=?1; } } cout?<<?cur?<<?"?occurs?" <<?cnt?<<?"?times"?<<?endl; } return?0; }
最后一個(gè)數(shù)是多少次輸不出來