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?
8 Months Ago
Related Article:2 Dimensional Array input/output
is a solved C++ discussion thread by ShEeRMiLiTaNt that has 9 replies, was last updated 9 months ago and has been tagged with the keywords: 2, dimensional, 2d, array, input, output.
Extract digits from count and insert them in an array.
Finding largest element in an array.
max = array ;
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.