I'm trying to write a program where in you input 9 numbers from 1-10, then it determines the missing number. Here's my code. It has a lot of errors. Help me do the right structure. Maybe after that, I'll improve it by setting conditions like no repetition/ 0< number <10. Just help me to fix this first:
-
#include <iostream>
-
using namespace std;
-
-
int main()
-
{
-
int d[]={1,2,3,4,5,6,1,7,9, 10};
-
int i=0,j=0,c=0,missing=0;
-
-
for (i = 0; i < 9; i++)
-
{
-
cout << "input: ";
-
cin >> d[i];
-
c = 0;
-
for (j = 0; j<10; j++)
-
{
-
if (i == d[j])
-
{
-
c = i;
-
}
-
}
-
if (i==d[j])
-
{
-
missing = j;
-
-
}
-
}
-
cout << "missing is " << missing << endl;
-
return 0;
-
}
-
-
I'm so new to C++. It always prints out the number 10 even though I typed it already. I really have no idea how to determine the missing one.