void main() { int ch,ch1,ch2,ch3; fm=fopen("member.dat","a+"); ft=fopen("trans.dat","a+"); fb=fopen("book.dat","a+"); mainscr(); while(1) { bk: showmenu(mainmenu,5,10,35); ch=getchoice(mainmenu,"MBRHE",10,35,5); switch(ch) { case 1:bk1: showmenu(memmenu,4,10,35); ch1=getchoice(memmenu,"ARIB",10,35,4); switch(ch1) { case 1: addmember(); goto bk1; case 2: renewmem(); goto bk1; case 3: memdupid(); goto bk1; case 4: goto bk; } break; case 2:bk2: showmenu(bookmenu,4,10,35); ch2=getchoice(bookmenu,"AIRB",10,35,4); switch(ch2) { case 1: addbook(); goto bk2; case 2: issbook(); goto bk2; case 3: retbook(); goto bk2; case 4: goto bk; } break; case 3:bk3: showmenu(rptmenu,4,10,35); ch3=getchoice(rptmenu,"MBTB",10,35,4); switch(ch3) { case 1: allmem(); goto bk3; case 2: allbook();goto bk3; case 3: alltransac();goto bk3; case 4: goto bk; } break; case 4: showhelp(); break; case 5:fclose(ft); fclose(fm); fclose(fb); exit(); } } }
main() { clrscr(); for(loading = 0; loading <= 100; loading++) { delay(9999999); clrscr(); printf("Loading TicTacToe %d...", loading); } delay(9999999); while(gameover != 1) { if((nextplayer == 1)&&(gameover == 0)) { mainscr(); printf("Player %d: What Box? ", nextplayer); { scanf("%d", &box); if((box < 1)||(box > 9)) { printf("Input Error: Number must be from 1-9..."); getch(); nextplayer = 1; } else if((box > 1)||(box < 9)) { if((ch[box] == 'x')||(ch[box] == 'o')) { printf("Input Error: Input in an empty box..."); getch(); nextplayer = 1; } else if((ch[box] != 'x')||(ch[box] != 'o')) { ch[box] = 'x'; { if(ch[1] == 'x') { if((ch[2] == 'x') && (ch[3] == 'x')) { winner = 1; gameover = 1; } } if(ch[4] == 'x') { if((ch[5] == 'x')&&(ch[6] == 'x')) { winner = 1; gameover = 1; } } if(ch[7] == 'x') { if((ch[8] == 'x')&&(ch[9] == 'x')) { winner = 1; gameover = 1; } } if(ch[1] == 'x') { if((ch[4] == 'x')&&(ch[7] == 'x')) { winner = 1; gameover = 1; } } if(ch[2] == 'x') { if((ch[5] == 'x')&&(ch[8] == 'x')) { winner = 1; gameover = 1; } } if(ch[3] == 'x') { if((ch[6] == 'x')&&(ch[9] == 'x')) { winner = 1; gameover = 1; } } if(ch[5] == 'x') { if((ch[1] == 'x')&&(ch[9] == 'x')) { winner = 1; gameover = 1; } } if(ch[5] == 'x') { if((ch[3] == 'x')&&(ch[7] == 'x')) { winner = 1; gameover = 1; } } } nextplayer = 2; } } } } if((nextplayer == 2)&&(gameover == 0)) { mainscr(); printf("Player %d: What Box? ", nextplayer); { scanf("%d", &box); if((box < 1)||(box > 9)) { printf("Input Error: Number must be from 1-9..."); getch(); nextplayer = 2; } else if((box < 9)||(box > 1)) { if((ch[box] == 'x')||(ch[box] == 'o')) { printf("Input Error: Input in an empty box..."); getch(); nextplayer = 2; } else if((ch[box] != 'x')||(ch[box] != 'o')) { ch[box] = 'o'; { if(ch[1] == 'o') { if((ch[2] == 'o') && (ch[3] == 'o')) { winner = 2; gameover = 1; } } if(ch[4] == 'o') { if((ch[5] == 'o')&&(ch[6] == 'o')) { winner = 2; gameover = 1; } } if(ch[7] == 'o') { if((ch[8] == 'o')&&(ch[9] == 'o')) { winner = 2; gameover = 1; } } if(ch[1] == 'o') { if((ch[4] == 'o')&&(ch[7] == 'o')) { winner = 2; gameover = 1; } } if(ch[2] == 'o') { if((ch[5] == 'o')&&(ch[8] == 'o')) { winner = 2; gameover = 1; } } if(ch[3] == 'o') { if((ch[6] == 'o')&&(ch[9] == 'o')) { winner = 2; gameover = 1; } } if(ch[5] == 'o') { if((ch[1] == 'o')&&(ch[9] == 'o')) { winner = 2; gameover = 1; } } if(ch[5] == 'o') { if((ch[3] == 'o')&&(ch[7] == 'o')) { winner = 2; gameover = 1; } } } nextplayer = 1; } } } } } mainscr(); printf("Game Over!\n"); printf("Winner: Player %d!\n\n", winner); printf("Press Any Key To Continue..."); getch(); }
void maingame3x3() { while(gameover != 1) { if((nextplayer == 1)&&(gameover == 0)) { mainscr(); scr3x3(); gotoxy(72,11); printf("%s", name[0]); gotoxy(46,19); printf("What Box? "); { scanf("%d", &box); if((box < 1)||(box > 9)) { mainscr(); scr3x3(); gotoxy(46,19); printf("Input Error"); gotoxy(45,20); printf("Input Box 1-9."); gotoxy(45,21); printf("Press Any Key..."); getch(); nextplayer = 1; } else if((box > 1)||(box < 9)) { if(((ch[box] == 'x')||(ch[box] == 'o'))&&(cheats == 0)) { mainscr(); scr3x3(); gotoxy(46,19); printf("Input Error"); gotoxy(45,20); printf("Input in an empty box."); gotoxy(45,21); printf("Press Any Key..."); getch(); nextplayer = 1; } else if((ch[box] != 'x')||(ch[box] != 'o')) { ch[box] = 'x'; { if(((ch[1] == 'x')||(ch[1] == 'o'))&&((ch[2] == 'x')||(ch[2] == 'o'))&&((ch[3] == 'x')||(ch[3] == 'o'))&&((ch[4] == 'x')||(ch[4] == 'o'))&&((ch[5] == 'x')||(ch[5] == 'o'))&&((ch[6] == 'x')||(ch[6] == 'o'))&&((ch[7] == 'x')||(ch[7] == 'o'))&&((ch[8] == 'x')||(ch[8] == 'o'))&&((ch[9] == 'x')||(ch[9] == 'o'))) { strcpy(winner,"None"); draw = draw + 1; gameover = 1; } if(ch[1] == 'x') { if((ch[2] == 'x') && (ch[3] == 'x')) { strcpy(winner,name[0]); wins[0] = wins[0] + 1; lose[1] = lose[1] + 1; gameover = 1; } } if(ch[4] == 'x') { if((ch[5] == 'x')&&(ch[6] == 'x')) { strcpy(winner,name[0]); wins[0] = wins[0] + 1; lose[1] = lose[1] + 1; gameover = 1; } } if(ch[7] == 'x') { if((ch[8] == 'x')&&(ch[9] == 'x')) { strcpy(winner,name[0]); wins[0] = wins[0] + 1; lose[1] = lose[1] + 1; gameover = 1; } } if(ch[1] == 'x') { if((ch[4] == 'x')&&(ch[7] == 'x')) { strcpy(winner,name[0]); wins[0] = wins[0] + 1; lose[1] = lose[1] + 1; gameover = 1; } } if(ch[2] == 'x') { if((ch[5] == 'x')&&(ch[8] == 'x')) { strcpy(winner,name[0]); wins[0] = wins[0] + 1; lose[1] = lose[1] + 1; gameover = 1; } } if(ch[3] == 'x') { if((ch[6] == 'x')&&(ch[9] == 'x')) { strcpy(winner,name[0]); wins[0] = wins[0] + 1; lose[1] = lose[1] + 1; gameover = 1; } } if(ch[5] == 'x') { if((ch[1] == 'x')&&(ch[9] == 'x')) { strcpy(winner,name[0]); wins[0] = wins[0] + 1; lose[1] = lose[1] + 1; gameover = 1; } } if(ch[5] == 'x') { if((ch[3] == 'x')&&(ch[7] == 'x')) { strcpy(winner,name[0]); wins[0] = wins[0] + 1; lose[1] = lose[1] + 1; gameover = 1; } } } nextplayer = 2; } } } } if((nextplayer == 2)&&(gameover == 0)) { mainscr(); scr3x3(); gotoxy(72,11); printf("%s", name[1]); gotoxy(46,19); printf("What Box? "); { scanf("%d", &box); if((box < 1)||(box > 9)) { mainscr(); scr3x3(); gotoxy(46,19); printf("Input Error"); gotoxy(45,20); printf("Input Box 1-9."); gotoxy(45,21); printf("Press Any Key..."); getch(); nextplayer = 2; } else if((box < 9)||(box > 1)) { if(((ch[box] == 'x')||(ch[box] == 'o'))&&(cheats == 0)) { mainscr(); scr3x3(); gotoxy(46,19); printf("Input Error"); gotoxy(45,20); printf("Input in an empty box."); gotoxy(45,21); printf("Press Any Key..."); getch(); nextplayer = 2; } else if((ch[box] != 'x')||(ch[box] != 'o')) { ch[box] = 'o'; { if(((ch[1] == 'x')||(ch[1] == 'o'))&&((ch[2] == 'x')||(ch[2] == 'o'))&&((ch[3] == 'x')||(ch[3] == 'o'))&&((ch[4] == 'x')||(ch[4] == 'o'))&&((ch[5] == 'x')||(ch[5] == 'o'))&&((ch[6] == 'x')||(ch[6] == 'o'))&&((ch[7] == 'x')||(ch[7] == 'o'))&&((ch[8] == 'x')||(ch[8] == 'o'))&&((ch[9] == 'x')||(ch[9] == 'o'))) { strcpy(winner,"None"); draw = draw + 1; gameover = 1; } if(ch[1] == 'o') { if((ch[2] == 'o') && (ch[3] == 'o')) { strcpy(winner,name[1]); wins[1] = wins[1] + 1; lose[0] = lose[0] + 1; gameover = 1; } } if(ch[4] == 'o') { if((ch[5] == 'o')&&(ch[6] == 'o')) { strcpy(winner,name[1]); wins[1] = wins[1] + 1; lose[0] = lose[0] + 1; gameover = 1; } } if(ch[7] == 'o') { if((ch[8] == 'o')&&(ch[9] == 'o')) { strcpy(winner,name[1]); wins[1] = wins[1] + 1; lose[0] = lose[0] + 1; gameover = 1; } } if(ch[1] == 'o') { if((ch[4] == 'o')&&(ch[7] == 'o')) { strcpy(winner,name[1]); wins[1] = wins[1] + 1; lose[0] = lose[0] + 1; gameover = 1; } } if(ch[2] == 'o') { if((ch[5] == 'o')&&(ch[8] == 'o')) { strcpy(winner,name[1]); wins[1] = wins[1] + 1; lose[0] = lose[0] + 1; gameover = 1; } } if(ch[3] == 'o') { if((ch[6] == 'o')&&(ch[9] == 'o')) { strcpy(winner,name[1]); wins[1] = wins[1] + 1; lose[0] = lose[0] + 1; gameover = 1; } } if(ch[5] == 'o') { if((ch[1] == 'o')&&(ch[9] == 'o')) { strcpy(winner,name[1]); wins[1] = wins[1] + 1; lose[0] = lose[0] + 1; gameover = 1; } } if(ch[5] == 'o') { if((ch[3] == 'o')&&(ch[7] == 'o')) { strcpy(winner,name[1]); wins[1] = wins[1] + 1; lose[0] = lose[0] + 1; gameover = 1; } } } nextplayer = 1; } } } } } mainscr(); scr3x3(); gotoxy(46,19); printf("Winner: %s!",winner); if(stricmp(winner,"None") == 0) { mainscr(); scr3x3(); gotoxy(46,19); printf("Game Draw!"); } gotoxy(45,20); printf("Press Any Key..."); getch(); }
main() { clrscr(); textbackground(BLACK); textcolor(LIGHTCYAN); for(loading = 0; loading <= 0; loading++) { delay(9999999); clrscr(); printf("Loading TicTacToe %d%%...", loading); } delay(9999999); while(exiton != 1) { for(y = 0; y < 8; y ++) { x[y] = 32; } for(y = 1; y < 17; y ++) { ch[y] = 32; } mainscr(); if(version == 1) { scr3x3(); } else if(version == 2) { scr4x4(); } gotoxy(46,19); printf("Enter Command: "); scanf("%d", &cmd); if(cmd == 0) { if(cheats == 0) { cheats = 1; strcpy(ce,"On "); mainscr(); if(version == 1) { scr3x3(); } else if(version == 2) { scr4x4(); } gotoxy(46,19); printf("Cheats Activated!"); gotoxy(45,20); printf("Press Any Key..."); getch(); } else if(cheats == 1) { cheats = 0; strcpy(ce,"Off"); mainscr(); if(version == 1) { scr3x3(); } else if(version == 2) { scr4x4(); } gotoxy(46,19); printf("Cheats Deactivated!"); gotoxy(45,20); printf("Press Any Key..."); getch(); } } if(cmd == 1) { game = 0; newgame = 0; cont = 0; gameover = 0; nextplayer = 1; for(box = 1; box < 17; box++) { ch[box] = ' '; } wins[0] = 0; wins[1] = 0; lose[0] = 0; lose[1] = 0; draw = 0; x[0] = 16; x[1] = 17; strcpy(name[0],"P1"); strcpy(name[1],"P2"); mainscr(); gotoxy(46,19); printf("Enter Version: "); gotoxy(45,21); printf("Version 1: 3 by 3"); gotoxy(45,22); printf("Version 2: 4 by 4"); gotoxy(61,19); scanf("%d", &version); if((version == 1)||(version == 2)) { game = 1; newgame = 1; mainscr(); if(version == 1) { scr3x3(); } else if(version == 2) { scr4x4(); } gotoxy(46,19); printf("Enter Name P1: "); scanf("%s",name[0]); mainscr(); if(version == 1) { scr3x3(); } else if(version == 2) { scr4x4(); } gotoxy(46,19); printf("Enter Name P2: "); scanf("%s",name[1]); if(version == 1) { maingame3x3(); } else if(version == 2) { maingame4x4(); } } else { mainscr(); gotoxy(46,19); printf("Input Error"); gotoxy(45,20); printf("Version 1 or 2 only please."); gotoxy(45,21); printf("Press Any Key..."); getch(); } } if(cmd ==2) { if(game != 0) { newgame = 0; cont = 1; gameover = 0; nextplayer = 1; game = game + 1; for(box = 1; box < 17; box++) { ch[box] = ' '; } x[2] = 16; x[3] = 17; if(((wins[0] != 3)||(wins[1] != 3))||(game < 10)) { if(version == 1) { maingame3x3(); } else if(version == 2) { maingame4x4(); } } if(wins[0] == 3) { mainscr(); if(version == 1) { scr3x3(); } else if(version == 2) { scr4x4(); } gotoxy(2,4); printf("Game Over!"); gotoxy(2,5); printf("Winner: %s!",name[0]); gotoxy(46,19); printf("Press Any Key..."); getch(); wins[0] = 0; wins[1] = 0; lose[0] = 0; lose[1] = 0; draw = 0; newgame = 0; cont = 0; game = 0; nextplayer = 0; strcpy(name[0],"P1"); strcpy(name[1],"P2"); } else if(wins[1] == 3) { mainscr(); if(version == 1) { scr3x3(); } else if(version == 2) { scr4x4(); } gotoxy(2,4); printf("Game Over!"); gotoxy(2,5); printf("Winner: %s!",name[1]); gotoxy(46,19); printf("Press Any Key..."); getch(); wins[0] = 0; wins[1] = 0; lose[0] = 0; lose[1] = 0; draw = 0; newgame = 0; cont = 0; game = 0; nextplayer = 0; strcpy(name[0],"P1"); strcpy(name[1],"P2"); } else if((game == 9)&&((wins[0] != 3)||(wins[1] != 3))) { mainscr(); if(version == 1) { scr3x3(); } else if(version == 2) { scr4x4(); } gotoxy(2,4); printf("Game Over!"); gotoxy(2,5); printf("It's A Draw!"); gotoxy(45,19); printf("Press Any Key..."); getch(); wins[0] = 0; wins[1] = 0; lose[0] = 0; lose[1] = 0; draw = 0; newgame = 0; cont = 0; game = 0; nextplayer = 0; strcpy(name[0],"P1"); strcpy(name[1],"P2"); } } else { mainscr(); if(version == 1) { scr3x3(); } else if(version == 2) { scr4x4(); } gotoxy(46,19); printf("Input Error"); gotoxy(45,20); printf("Cannot continue, try a new game."); gotoxy(45,21); printf("Press Any Key..."); getch(); } } if(cmd == 3) { x[4] = 16; x[5] = 17; mainscr(); gotoxy(2,4); printf("You need to match 'x' or 'o' in a line."); gotoxy(2,5); printf("You must score 3 points in 9 games to win."); gotoxy(2,7); printf("Tic Tac Toe Version 2.4"); gotoxy(2,8); printf("-Fixed 'continue bug'."); gotoxy(2,9); printf("-Created new 4 by 4 Tic Tac Toe."); gotoxy(2,10); printf("-New Interface"); gotoxy(2,12); printf("Beta Testers:"); gotoxy(2,13); printf("-Reed"); gotoxy(2,14); printf("-Byn"); gotoxy(46,19); printf("Press Any Key..."); getch(); } if(cmd == 4) { x[6] = 16; x[7] = 17; exiton = 1; } if((cmd > 4)||(cmd < 0)) { mainscr(); if(version == 1) { scr3x3(); } else if(version == 2) { scr4x4(); } gotoxy(46,19); printf("Input Error"); gotoxy(46,20); printf("Enter Command (1-4)."); gotoxy(46,21); printf("Press Any Key..."); getch(); } } mainscr(); if(version == 1); { scr3x3(); } if(version == 2); { scr4x4(); } gotoxy(46,19); printf("Press Any Key To Exit..."); getch(); }
main() { clrscr(); textbackground(BLACK); textcolor(LIGHTCYAN); for(loading = 0; loading <= 100; loading++) { delay(9999999); clrscr(); printf("Loading TicTacToe %d%%...", loading); } delay(9999999); while(exiton != 1) { for(y = 0; y < 8; y ++) { x[y] = 32; } for(y = 1; y < 10; y ++) { ch[y] = 32; } mainscr(); gotoxy(3,18); printf("Enter Command:"); gotoxy(23,18); scanf("%d", &cmd); if(cmd == 0) { if(cheats == 0) { cheats = 1; strcpy(ce,"On "); mainscr(); gotoxy(41,5); printf("Cheats Activated!"); gotoxy(23,18); printf("Press Any Key..."); getch(); } else if(cheats == 1) { cheats = 0; strcpy(ce,"Off"); mainscr(); gotoxy(41,5); printf("Cheats Deactivated!"); gotoxy(23,18); printf("Press Any Key..."); getch(); } } if(cmd == 1) { newgame = 1; cont = 0; gameover = 0; nextplayer = 1; game = 1; for(box = 1; box < 10; box++) { ch[box] = ' '; } wins[0] = 0; wins[1] = 0; lose[0] = 0; lose[1] = 0; draw = 0; x[0] = 16; x[1] = 17; strcpy(name[0],"P1"); strcpy(name[1],"P2"); mainscr(); gotoxy(3,18); printf("Enter Name P1:"); gotoxy(23,18); scanf("%s",name[0]); mainscr(); gotoxy(3,18); printf("Enter Name P2:"); gotoxy(23,18); scanf("%s",name[1]); maingame(); } if(cmd ==2) { if(game != 0) { newgame = 0; cont = 1; gameover = 0; nextplayer = 1; game = game + 1; for(box = 1; box < 10; box++) { ch[box] = ' '; } x[2] = 16; x[3] = 17; if(((wins[0] != 3)||(wins[1] != 3))||(game < 10)) { maingame(); } if(wins[0] == 3) { mainscr(); gotoxy(41,5); printf("Game Over!"); gotoxy(41, 6); printf("Winner: %s!",name[0]); gotoxy(23,18); printf("Press Any Key..."); getch(); wins[0] = 0; wins[1] = 0; lose[0] = 0; lose[1] = 0; draw = 0; newgame = 0; cont = 0; game = 0; nextplayer = 0; strcpy(name[0],"P1"); strcpy(name[1],"P2"); } else if(wins[1] == 3) { mainscr(); gotoxy(41,5); printf("Game Over!"); gotoxy(41, 6); printf("Winner: %s!",name[1]); gotoxy(23,18); printf("Press Any Key..."); getch(); wins[0] = 0; wins[1] = 0; lose[0] = 0; lose[1] = 0; draw = 0; newgame = 0; cont = 0; game = 0; nextplayer = 0; strcpy(name[0],"P1"); strcpy(name[1],"P2"); } else if((game == 9)&&((wins[0] != 3)||(wins[1] != 3))) { mainscr(); gotoxy(41,5); printf("Game Over!"); gotoxy(41, 6); printf("It's A Draw!"); gotoxy(23,18); printf("Press Any Key..."); getch(); wins[0] = 0; wins[1] = 0; lose[0] = 0; lose[1] = 0; draw = 0; newgame = 0; cont = 0; game = 0; nextplayer = 0; strcpy(name[0],"P1"); strcpy(name[1],"P2"); } } else { mainscr(); gotoxy(23,18); printf("Input Error: Cannot continue, try a new game..."); getch(); } } if(cmd == 3) { x[4] = 16; x[5] = 17; mainscr(); gotoxy(41,5); printf("You need to match 3 "); gotoxy(41,6); printf("'x' (if player 1) or"); gotoxy(41,7); printf("3 'o' (if player 2) "); gotoxy(41,8); printf("in a line."); gotoxy(41,10); printf("You must score 3 "); gotoxy(41, 11); printf("points in 9 games "); gotoxy(41, 12); printf("to win."); gotoxy(41,14); printf("Help by: Reed"); gotoxy(23,18); printf("Press Any Key..."); getch(); } if(cmd == 4) { x[6] = 16; x[7] = 17; exiton = 1; } if((cmd > 4)||(cmd < 0)) { mainscr(); gotoxy(23,18); printf("Input Error: Enter Command (1-4)"); getch(); } } mainscr(); gotoxy(23,18); printf("Press Any Key To Exit..."); getch(); }