#include <iostream>
const int turns = 2022;
int processing(int array[], int number, int index);
int main()
{
int numLine[turns]; //actual number line
//int counter = 0; //turns since last refference??
int previousNumber;
for (int i = 0; i < 7; i++) //for seven turns
{
std::cout << "Seed Number " << i+1 << ": "; //Seed Numer 1,2,3... :
std::cin >> numLine[i]; //input number
std::cout << std::endl; // endline
}
for (int i = 7; i < turns; i++) //for the entire length of the turns after 7
{
previousNumber = numLine[i - 1];
numLine[i] = processing(numLine, previousNumber, i-2); //set the current element of numLine to the processed number
std::cout << numLine[i] << " ";
}
}
int processing(int array[], int number, int index) //processing seeded with int number
{
int counter = -1; // number of turns since last referrence
for (int i = index; i >= 0; i--) //searches down from index to 0
{
if (array[i] == number) {
counter = i; //times since its been said
}
}
if (counter == -1)
{
return 0;
}
else
return counter;
//has been seen before so return the count
}
// 13,16,10,12,1,5,8 (seed numbers)
This is my code, this is the prompt that I was given to design my program: http://cis.scc.losrios.edu/~TownJ/dinosaur/memory.html
When inputting the seed numbers required for the prompt, the output I receive is 9 (for the 2022nd element of the array, this code outputs all the elements) but when putting that into the website, it is incorrect, as is the number before it. I can't see what I am doing wrong, could someone with more experience tell me what I messed up?