Hallo everyone,
I have written the below code but it doesn't work right.
The problem is that when I run it, and
the score_main array has a value of -3 or 3 and at the same time
the move_main is 9, I get as a "result" the number 3, which is wrong
according to this:
[CODE=c] for (i=0; i<8; i++)
{
if ((move_main==9) && ((score_main[i]!=3) || (score_main[i]!=-3)))
{
result=3;
}
}[/code]
where is my mistake???@#%#@ !!! :(
Here is the whole code:
[code=c]#include <stdio.h>
#include <stdlib.h>
int main()
{
int score_main[8]={0,1,-2,-1,-3,1,0,1};
int move_main=9;
int i,result;
for (i=0; i<8; i++)
{
if (score_main[i]==3)
{
result=1;
}
}
for (i=0; i<8; i++)
{
if (score_main[i]==-3)
{
result=2;
}
}
for (i=0; i<8; i++)
{
if ((move_main<9) && ((score_main[i]!=3) || (score_main[i]!=-3)))
{
result=0;
}
}
for (i=0; i<8; i++)
{
if ((move_main==9) && ((score_main[i]!=3) || (score_main[i]!=-3)))
{
result=3;
}
}
printf("%d\n", result);
system("PAUSE") ;
}[/CODE]
I have written the below code but it doesn't work right.
The problem is that when I run it, and
the score_main array has a value of -3 or 3 and at the same time
the move_main is 9, I get as a "result" the number 3, which is wrong
according to this:
[CODE=c] for (i=0; i<8; i++)
{
if ((move_main==9) && ((score_main[i]!=3) || (score_main[i]!=-3)))
{
result=3;
}
}[/code]
where is my mistake???@#%#@ !!! :(
Here is the whole code:
[code=c]#include <stdio.h>
#include <stdlib.h>
int main()
{
int score_main[8]={0,1,-2,-1,-3,1,0,1};
int move_main=9;
int i,result;
for (i=0; i<8; i++)
{
if (score_main[i]==3)
{
result=1;
}
}
for (i=0; i<8; i++)
{
if (score_main[i]==-3)
{
result=2;
}
}
for (i=0; i<8; i++)
{
if ((move_main<9) && ((score_main[i]!=3) || (score_main[i]!=-3)))
{
result=0;
}
}
for (i=0; i<8; i++)
{
if ((move_main==9) && ((score_main[i]!=3) || (score_main[i]!=-3)))
{
result=3;
}
}
printf("%d\n", result);
system("PAUSE") ;
}[/CODE]
Comment