fork(1) download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. int main(){
  5. int a, b = 0, c = 0, d = 1, e = 0, f;
  6. cin >> a;
  7. do{
  8. if(a != 0 && b == 0){
  9. if(c != a && e == 0){
  10. d++;
  11. }
  12. else{
  13. e++;
  14. }
  15. c = a;
  16. }
  17. else{
  18. b++;
  19. }
  20. }while(cin >> a);
  21. cout << d;
  22. return 0;
  23. }
Success #stdin #stdout 0s 5320KB
stdin
1 7 7 9 1 0



stdout
3