fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. size_t count=0;
  7. int value=0;
  8. for(int curr=0;(cin>>curr)&&(curr);value=curr,++count)
  9. {
  10. if((!count)||(value!=curr)) count=0;
  11. }
  12. if(count) cout<<count<<" times "<<value<<endl;
  13. else cout<<"0 times nothing";
  14. return 0;
  15. }
Success #stdin #stdout 0s 4488KB
stdin
1 2 3 1 2 3 1 2 3 2
stdout
1 times 2