Nov 3, 2011 at 12:33am UTC
Hey can't find out why this in incrementing wrong. It should increment the function check answers 128 time, however it is only incrementing it about 50-60 times and idk why that is.
Here is the code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
for (int x=0;x<2;x++){
for (int y=0;y<4;y++){
for (int z=0;z<16;z++)
{
if (kids[x][y][z].getSN()==0){
kids[x][y][z].checkAnswers(tempA);
kids[x][y][z].getCorrect(tempE);
A[0].findCorrect(tempE);
kids[x][y][z].checkGrade();
if (x=0)
A[0].correctSecOne(tempE);
if (x=1)
A[0].correctSecTwo(tempE);
for (int g=0;g<100;g++)
tempKids[x][y][z][g]=tempE[g];
}
if (kids[x][y][z].getSN()==1){
kids[x][y][z].checkAnswers(tempB);
kids[x][y][z].getCorrect(tempE);
A[1].findCorrect(tempE);
kids[x][y][z].checkGrade();
if (x=0)
A[1].correctSecOne(tempE);
if (x=1)
A[1].correctSecTwo(tempE);
for (int g=0;g<100;g++)
tempKids[x][y][z][g]=tempE[g];
}
if (kids[x][y][z].getSN()==2){
kids[x][y][z].checkAnswers(tempC);
kids[x][y][z].getCorrect(tempE);
A[2].findCorrect(tempE);
kids[x][y][z].checkGrade();
if (x=0)
A[2].correctSecOne(tempE);
if (x=1)
A[2].correctSecTwo(tempE);
for (int g=0;g<100;g++)
tempKids[x][y][z][g]=tempE[g];
}
if (kids[x][y][z].getSN()==3){
kids[x][y][z].checkAnswers(tempD);
kids[x][y][z].getCorrect(tempE);
A[3].findCorrect(tempE);
kids[x][y][z].checkGrade();
if (x=0)
A[3].correctSecOne(tempE);
if (x=1)
A[3].correctSecTwo(tempE);
for (int g=0;g<100;g++)
tempKids[x][y][z][g]=tempE[g];
}
}
}
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
void Students::checkAnswers(const int a[100][2]){
//Variable to hold the test answers
/*int theKey[100][2];
for(int i=0;i<100;i++)
{
theKey[i][0] = a[i][0];
theKey[i][1] = a[i][1];
}
*/
//checks students answers to key
ofstream output;
output.open("Check Answers output.txt" ,ios::app);
for (int i=0;i<100;i++)//NOT !!! WORKINGGGGG
{
if (answers[i]==a[i][0]||answers[i]==a[i][1])
{
totalCorrect[i]=1;
}
else
{
totalCorrect[i]=0;
}
output<<totalCorrect[i]<<endl;
}
output<<"///////" <<endl;
output.close();
}
Last edited on Nov 3, 2011 at 12:40am UTC
Nov 3, 2011 at 12:36am UTC
You should edit that block of crap so that the closing code blocks look like: [ / code ]
Nov 3, 2011 at 12:40am UTC
Aight did that, forgot it was the other way around.
Nov 3, 2011 at 12:43am UTC
You code in frustration comments the same way my brother does.
How many times exactly does it increment? 64?
Nov 3, 2011 at 12:46am UTC
Yea 65 times do you know why that is?
Last edited on Nov 3, 2011 at 12:46am UTC
Nov 3, 2011 at 12:51am UTC
I feel like I'm missing something. It's ignoring the second iteration of x, but I don't know why. What's the scope of the three for() loops that you posted? And can I see the next higher level of code?
Nov 4, 2011 at 7:06pm UTC
You have assignment operators in your ifs
1 2
if (x=0) // assigns x the value 0
if (x=1) // assigns x the value 1
This messing with the loop control variables is probably the cause of the problem
Last edited on Nov 4, 2011 at 7:06pm UTC