jeudi 11 octobre 2018

How to continue a consecutive pattern in c?

My input is entry[] = {1,2,1,1,2,1,2,3,1,2,1,1,2,1,2,-1} the program has to return with the number that comes next in the pattern.

This is how far I have gotten, but I can't seem to figure it out.

int forecast(int entry[]) {
int i, j;
   for (i = 0; (i - 1) != -1; i++) {
       for (j = i + 1; (j - 1) != -1; j++) {
           if (entry[j] == entry[i] {

           }
       }
   }
}

Aucun commentaire:

Enregistrer un commentaire