You are viewing a single comment's thread. Return to all comments →
int main(){ int n, r,c; cin >> n; while(n!=0){ r = n%2; n = n/2; if(r ==1){ c +=1; } else if(r ==0){ c = 0; } } cout<< c; return 0; }
can anyone tell me what is the problem in my code. Test case 2 is not satisfying.
Seems like cookies are disabled on this browser, please enable them to open this website
Consecutive 1's in Binary Numbers
You are viewing a single comment's thread. Return to all comments →
can anyone tell me what is the problem in my code. Test case 2 is not satisfying.