vendredi 30 septembre 2016

converting for loop to while loop/ or if loop

Program: loop through array and find the maximum count of a value that appear

I need to convert this to while or if loop can someone please show me

int max_len(int array[], int size)
    {
       int previous = array[0], count = 1, i = 0, maxCount = 1;

   for (i = 1; i < size; i++)
      (array[i] == previous)? count++: (previous = array[i],
              (maxCount < count)? maxCount = count : count = 1);
   return maxCount;
}enter code here

//I'm a bit new to this

Aucun commentaire:

Enregistrer un commentaire