You are viewing a single comment's thread. Return to all comments →
why do you need a modulus operator? you should name your variables better so that they are easier to read and understand quickly.
int main(){ int count =0; int max = 0; int n; cin >> n;
while(n){ if (n&1){ count++; } else { count = 0; } if (max < count) max = count; n>>=1; } cout << max; return 0;
}
Seems like cookies are disabled on this browser, please enable them to open this website
Day 10: Binary Numbers
You are viewing a single comment's thread. Return to all comments →
why do you need a modulus operator? you should name your variables better so that they are easier to read and understand quickly.
int main(){ int count =0; int max = 0; int n; cin >> n;
}