fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. while(true)
  6. {
  7. int n,count=0,max=0;
  8. cin>>n;
  9. if(n<0) break;
  10. while(n!=0)
  11. {
  12. if(n%2==0)
  13. {
  14. if(count>max)
  15. max=count;
  16. count=0;
  17. }
  18. else
  19. sum++;
  20. n/=2;
  21. }
  22. if(count>max)
  23. max=count;
  24. cout<<max<<endl;
  25. }
  26. return 0;
  27. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
78
64
23
89
-1
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:19:5: error: ‘sum’ was not declared in this scope
     sum++;
     ^~~
stdout
Standard output is empty