Here's my code for a tic-tac-toe game. It's incomplete, but almost done.

The computer doesn't seem to be taking a turn, unless the player has array[1]+array[2]=='X'. Can someone help me?Code:#include <iostream.h> #include <stdio.h> #include <time.h> #include <stdlib.h> char playagain='y'; char number; char array[10]; char i='1'; char compnumber; int main(void) { array[1]='1'; array[2]='2'; array[3]='3'; array[4]='4'; array[5]='5'; array[6]='6'; array[7]='7'; array[8]='8'; array[9]='9'; srand(time(NULL)); compnumber=rand()%10; while(playagain=='y') { i=1; cout << array[1]; cout << "|"; cout << array[2]; cout << "|"; cout << array[3]; cout << "\n-----\n"; cout << array[4]; cout << "|"; cout << array[5]; cout << "|"; cout << array[6]; cout << "\n-----\n"; cout << array[7]; cout << "|"; cout << array[8]; cout << "|"; cout << array[9]; cout << "\n"; cout << "Please enter the number of the space you would like to place an X in: "; cin >> number; for(i=i-'0';i<10;i++) // Player number calculation { if(number==i+'0' && array[i]!=i+'0') //Space already taken { cout << "That space is taken!\n"; } if(number==i+'0' && array[i]==i+'0') //Assigns X { array[i]='X'; } } if((array[1]=='X' && array[2]=='X') || (array[1]=='O' && array[2]=='O')) //Computer AI. Stops player win or finishes computer win. { compnumber='3'; } if((array[1]=='X' && array[5]=='X') || (array[1]=='O' && array[5]=='O')) { compnumber='9'; } if((array[1]=='X' && array[4]=='X') || (array[1]=='O' && array[4]=='O')) { compnumber='7'; } if((array[2]=='X' && array[5]=='X') || (array[2]=='O' && array[5]=='O')) { compnumber='8'; } if((array[3]=='X' && array[2]=='X') || (array[3]=='O' && array[2]=='O')) { compnumber='1'; } if((array[3]=='X' && array[5]=='X') || (array[3]=='O' && array[5]=='O')) { compnumber='7'; } if((array[3]=='X' && array[6]=='X') || (array[3]=='O' && array[6]=='O')) { compnumber='9'; } if((array[4]=='X' && array[5]=='X') || (array[4]=='O' && array[5]=='O')) { compnumber='3'; } else; { for(i=i-'0';i<10;i++) //Computer random number { while(compnumber==i+'0' && array[i]!=i+'0') //Space taken { srand(time(NULL)); compnumber=rand()%10; } if(compnumber==i+'0' && array[i]==i+'0') //Assigns O { array[i]='O'; } } } } return 0; }