1: Convert a decimal value to binary
2: Count the number of ones in the binary value
3: Count the largest number of 1 blocks (ex: 1001110111101111100's largest block has 5 1s)
I've done parts 1 and 2 but i'm having a little trouble with the loop required for part 3. So far all I have is a loop that checks through the array of 0s and 1s. I add to my blockcount variable if the current number in the array 1...but that's about it. I'm not sure where else to go from there if the number after that is a 0..
int x;
int y;
int i;
int bin_array[31];
int b;
int blockcount;
int maxcount;
int mincount;
if(bin_array[y] == 1)
{
blockcount++
}
else
{
???
}

New Topic/Question
Reply



MultiQuote






|