0

I'm causing input letters to write ones into variables through an array. I'm trying to count the occurences of ones in a variable. Lets say I input aaaaa. The count output displays 12345. Instead of outputting the whole count of numbers, I want to output the biggest number in the count. How can I do that?

3
Contributors
2
Replies
4
Views
4 Years
Discussion Span
Last Post by np complete
0

Here is hint for finding largest number in count.

Extract digits from count and insert them in an array.

Finding largest element in an array.

 max = array[0] ;

 i = 1;

 while ( i <= array length )
 {
    if( array[i] > max )
    {
       max = array[i] ;
    }

 }

How to extract digits from count ?

First do count modulo 10 and take remainder. It gives the last digit.
Then divide count by 10 and store it in an integer so that, the last digit is left out ( This happens because dividing integer by 10 gives a float value with decimal point before last digit ).
Continue the process untill dividing by 10 gives answer 0.

Hope this helps.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.