Not Yet Answered # How can I create a game of tic-tac-toe using c++

saloth Vllinator 1 Akill10 96 Greywolf333 11 Write a C program that should create a 10 element array of random integers (0 to 9). The program should total all of the numbers in the odd positions of the array and compare them with the total of the numbers in the even positions of the array and indicate ...

0

hello wintercold,

try using a two dimentional array.

char board[3][3];

then display the board first, then asked where to put the sign.

1

This is a really good tutorial

http://xoax.net/comp/cpp/console/Lesson9.php

If this is for a school project, be sure to not just copy the source code and make a few changes - you'll learn nothing that way.

Goodluck

0

This is a really good tutorial

http://xoax.net/comp/cpp/console/Lesson9.php

If this is for a school project, be sure to not just copy the source code and make a few changes - you'll learn nothing that way.

Goodluck

Wow, thanks for that website, i have never seen it before!

0

I'm a newbie in C++. How can I create a game of tic-tac-toe game using simple codes in C++? Any answers would be much appreciated.. Thanks!:)

Use prime numbers instead to make your professor go WTF.

```
#include <iostream>
#include <string>
using namespace std;
int main(){
int primes[9] = {2,3,5,7,11,13,17,19,23};
int x_primes = 1;
int o_primes = 1;
string b[9] = {"| |", "| |", "| |", "| |", "| |", "| |", "| |", "| |", "| |"};
char player = 'X';
int move;
while (x_primes * o_primes < 223092870){
cout << player << "'s turn. (press 0-8 where 0 is top left and 8 is bottom right)" << endl;
cin >> move;
if (player == 'X'){
x_primes *= primes[move];
b[move] = "| X |";
player = 'O';
}
else {
o_primes *= primes[move];
b[move] = "| O |";
player = 'X';
}
cout << b[0] << b[1] << b[2] << endl
<< "---------------\n"
<< b[3] << b[4] << b[5] << endl
<< "---------------\n"
<< b[6] << b[7] << b[8] << endl;
if (x_primes % 30 == 0 || x_primes % 1001 == 0 || x_primes % 7429 == 0 || x_primes % 238 == 0 || x_primes % 627 == 0 ||
x_primes % 1495 == 0 || x_primes % 506 == 0 || x_primes % 935 == 0){
cout << "X wins!" << endl; exit(0);
}
if (o_primes % 30 == 0 || o_primes % 1001 == 0 || o_primes % 7429 == 0 || o_primes % 238 == 0 || o_primes % 627 == 0 ||
o_primes % 1495 == 0 || o_primes % 506 == 0 || o_primes % 935 == 0){
cout << "Y wins!" << endl; exit(0);
}
}
cout << "Draw!" << endl;
return 0;
}
```

-Greywolf bored with SC2

This article has been dead for over six months. Start a new discussion instead.

Recommended Articles

Hi. so this is actually a continuation from another question of mineHere but i was advised to start a new thread as the original question was already answered.

This is the result of previous question answered :

code for the listbox - datagridview interaction

At the top of the code ...

the function that I created to find the ...