The Code-Bin
Links
Home
Add your code!
All Listings
About
Latest Entry
Featured Scripts
Author's Website
Latest Entries
FFMPEG Thumbnail Scr...
PHP, 0.8KB
Jul. 29, 10:24pm
John
Z80 Assembler, 190 bytes
Feb. 17, 3:36am
John
Z80 Assembler, 176 bytes
Sep. 13, 2:19am
John
Z80 Assembler, 77 bytes
Sep. 13, 2:18am
John
Z80 Assembler, 209 bytes
Sep. 13, 2:17am
untitled C Code
Posted by: lol | November 8, 2010 @ 9:20am
C Code
[
Download
]
#include <stdio.h> int jogo[3][3]; int jogar(int coord1, int coord2, int jogador) { if (jogo[coord1][coord2]==0) { jogo[coord1][coord2]=jogador; return 0; } else return 1; } int verificar() { int x; for (x=0; x<3; x++) { if (((jogo[x][0]==1) && (jogo[x][1]==1) && (jogo[x][2]==1)) || ((jogo[0][x]==1) && (jogo[1][x]==1) && (jogo[2][x]==1))) return 1; else if (((jogo[x][0]==2) && (jogo[x][1]==2) && (jogo[x][2]==2)) || ((jogo[0][x]==2) && (jogo[1][x]==2) && (jogo[2][x]==2))) return 2; } if (((jogo[0][0]==1) && (jogo[1][1]==1) && (jogo[2][2]==1)) || ((jogo[2][0]==1) && (jogo[1][1]==1) && (jogo[0][2]==1))) return 1; else if (((jogo[0][0]==2) && (jogo[1][1]==2) && (jogo[2][2]==2)) || ((jogo[2][0]==2) && (jogo[1][1]==2) && (jogo[0][2]==2))) return 2; return 0; } void novo() { int x, y; for (x=0; x<3; x++) { for (y=0; y<3; y++) { jogo[x][y]=0; } } } void mostrar() { int x, y; for (x=0; x<3; x++) { for (y=0; y<3; y++) { switch(jogo[y][x]) { case 0: printf(" "); break; case 1: printf("X"); break; case 2: printf("O"); break; } if (y!=2) printf("|"); } if (x!=2) printf("\n-----\n"); } printf("\n"); } int main() { int x, y; int i; novo(); mostrar(); while (verificar()==0) { for (i=1; i<3; i++) { scanf("%d %d", x, y); if (jogar(x, y, i)==1) printf("Erro fker"); } mostrar(); } return 0; }
Syntax Highlighting
[
Open in new window
]
Author Comments
none
Rating
4.49 / 8
35 Votes
http://codebin.yi.org/939
page generated in 0.00 seconds