Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- void message_1() {
- puts("+-----------------------------------------+");
- puts("| Welcome to TIC TAC TOE Game! |");
- puts("| Align 3 [x] characters to score points |");
- puts("| 1. Start playing now |");
- puts("| Press any other key to exit |");
- puts("+-----------------------------------------+");
- }
- void print_board(int points[9]) {
- puts(" + - + - + - +");
- puts(" | 1 | 2 | 3 |");
- puts("+ - + - + - + - + - +");
- if (points[0] == 1) {
- printf("| 1 | X |");
- } else {
- printf("| 1 | |");
- }
- if (points[1] == 1) {
- printf(" X ");
- } else {
- printf(" ");
- }
- if (points[2] == 1) {
- printf("| X | 3 |\n");
- } else {
- printf("| | 3 |\n");
- }
- puts("+ - + - + - + - + - +");
- if (points[3] == 1) {
- printf("| 4 | X |");
- } else {
- printf("| 4 | |");
- }
- if (points[4] == 1) {
- printf(" X ");
- } else {
- printf(" ");
- }
- if (points[5] == 1) {
- printf("| X | 6 |\n");
- } else {
- printf("| | 6 |\n");
- }
- puts("+ - + - + - + - + - +");
- if (points[6] == 1) {
- printf("| 7 | X |");
- } else {
- printf("| 7 | |");
- }
- if (points[7] == 1) {
- printf(" X ");
- } else {
- printf(" ");
- }
- if (points[8] == 1) {
- printf("| X | 9 |\n");
- } else {
- printf("| | 9 |\n");
- }
- puts("+ - + - + - + - +");
- puts(" | 7 | 8 | 9 |");
- puts(" + - + - + - +");
- }
- int main() {
- int choice, points[9], count = 0;
- message_1();
- scanf("%d", &choice);
- switch (choice) {
- case 1:
- while(count <= 9) {
- system("@cls||clear");
- print_board(points);
- printf(" Enter position number: ");
- scanf("%d", &choice);
- points[choice - 1] = 1;
- count++;
- }
- break;
- default:
- exit(0);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment