You are viewing a single comment's thread. Return to all comments →
Hello everyone this is my C solution.
int main() { int n = parse_int(ltrim(rtrim(readline()))); int consec = 0; int max = 0; while(n>0){ if ((n%2)==1) { consec++; } else{ if (consec>max) max =consec; consec = 0; } n /= 2; } consec>max ? printf("%d \n", consec):printf("%d \n", 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 →
Hello everyone this is my C solution.