Advertisement
Guest User

Untitled

a guest
Jun 30th, 2014
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 99.60 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <ctype.h>
  4. #include <windows.h>
  5.  
  6. /*declaração de funções*/
  7. void apresentacao();
  8. int menu(void);
  9. void funcaojogo();
  10. void jogo();
  11. void jogo1();
  12. void andar1 (void);
  13. void andar2 (void);
  14. void andar2 (void);
  15. int andarn1 ();
  16. int andarn2 ();
  17. int andarn3 ();
  18. int andarn4 ();
  19. void continua (void);
  20. void tutorial (void);
  21.  
  22. int main (void){
  23. system("color 30");
  24. apresentacao();
  25. menu();
  26. system("PAUSE");
  27. return 0;
  28. }
  29. void apresentacao(){ /** Introdução **/
  30. Sleep(2000);
  31. printf("\n\n\n\n\n\n\n");
  32. printf("\t\t _ _ _ \n");
  33. printf("\t\t| | (_) | | \n");
  34. printf("\t\t| |__ ___ _ __ ___ __ ___ _ __ __| | ___ \n");
  35. printf("\t\t| '_ \\ / _ \\\ '_ ` _ \\ \\ \\ / / | '_ \\ / _` |/ _ \\ \n");
  36. printf("\t\t| |_) | __/ | | | | | \\ V /| | | | | (_| | (_) |\n");
  37. printf("\t\t|_.__/ \\___|_| |_| |_| \\_/ |_|_| |_|\\__,_|\\___/ \n");
  38. printf("\n\n\n\n");
  39. Sleep(2000);
  40. system("cls");
  41. printf("\n\n\n\n\n\n");
  42. printf("\t _ _ __ __ _ _ \n");
  43. printf("\t | | | | \\ \\ / / | | | \n");
  44. printf("\t | | ___ __ _ ___ __| | __ _ \\ \\ / /__| | |__ __ _ \n");
  45. printf("\t _ | |/ _ \\ / _` |/ _ \\ / _` |/ _` | \\ \\/ / _ \\ | '_ \\ / _` | \n");
  46. printf("\t | |__| | (_) | (_| | (_) | | (_| | (_| | \\ / __/ | | | | (_| | \n");
  47. printf("\t \\____/ \\___/ \\__, |\\___/ \\__,_|\\__,_| \\/ \\___|_|_| |_|\\__,_| \n");
  48. printf("\t __/ | \n");
  49. printf("\t |___/ \n");
  50. Sleep(500);
  51. printf("\n\n");
  52. system("pause");
  53. }
  54. void continua(){
  55. int opc;
  56.  
  57. system ("cls");
  58.  
  59. do{
  60. printf("\t\t\t\tO que deseja fazer?\n(1)Voltar ao Menu.\n(2)Jogar Novamente.\n(3)Sair.\n");
  61. scanf("%d", &opc);
  62. }while(opc!=1 && opc!=2 && opc!=3);
  63. switch(opc){
  64. case 1:
  65. menu();
  66. case 2:
  67. funcaojogo();
  68. case 3:
  69. funcaojogo();
  70. break;
  71. }
  72. }
  73. struct jogadores
  74. {
  75. char player1[20],player2[20], player3[20];
  76. int pont1,pont2, pont3;
  77. } velha;
  78.  
  79. FILE*players,*ranking;
  80. struct jogadores velha;
  81.  
  82. void registro()
  83. {
  84. system ("cls");
  85. fwrite(&velha, sizeof(velha), 1, players);
  86. fwrite(&velha, sizeof(velha), 1, ranking);
  87. }
  88.  
  89. void escreve ()
  90. {
  91. system ("cls");
  92.  
  93. int opc;
  94. rewind(players);
  95. while(fread(&velha, sizeof(velha), 1, players)==1);
  96.  
  97. do{
  98. printf ("\t\t\t .-------------------------------. \n");
  99. printf ("\t\t\t | ** SCORES ** | \n");
  100. printf ("\t\t\t `-------------------------------' \n\n");
  101. printf ("\t\t\t 1 - Ver score do tabuleiro de 3 camadas.\n");
  102. printf ("\t\t\t 2 - Ver score do tabuleiro de 4 camadas.\n");
  103. printf ("\t\t\t 3 - Voltar ao menu.\n");
  104. scanf ("\t\t\t%d",&opc);
  105. } while (opc!=1 && opc!=2 && opc!=3);
  106.  
  107. switch (opc) {
  108.  
  109. case 1:
  110. system("cls");
  111. printf ("\t\t\t .-------------------------------. \n");
  112. printf ("\t\t\t | ** SCORES ** | \n");
  113. printf ("\t\t\t `-------------------------------' \n\n");
  114. printf ("\t\t\t Jogador\t\t\tPontos\n\n");
  115. printf ("\t\t\t %s\t\t\t%d\n", velha.player1, velha.pont1);
  116. printf ("\t\t\t %s\t\t\t%d\n", velha.player2, velha.pont2);
  117. system("pause");
  118. menu();
  119. case 2:
  120. system("cls");
  121. printf ("\t\t\t .-------------------------------. \n");
  122. printf ("\t\t\t | ** SCORES ** | \n");
  123. printf ("\t\t\t `-------------------------------' \n\n");
  124. printf ("\t\t\t Jogador\t\t\tPontos\n\n");
  125. printf ("\t\t\t %s\t\t\t%d\n", velha.player1, velha.pont1);
  126. printf ("\t\t\t %s\t\t\t%d\n", velha.player2, velha.pont2);
  127. printf ("\t\t\t %s\t\t\t%d\n", velha.player3, velha.pont3);
  128. system("pause");
  129. menu();
  130.  
  131. case 3:
  132. system("cls");
  133. menu();
  134. }
  135. }
  136. void cadastro ()
  137. {
  138. int opcao;
  139. players=fopen("players.txt","a");
  140.  
  141. if (players == NULL) //verifica se teve algo escrito no arquivo, caso nao ele ira voltar pro menu
  142. {
  143. printf("NAO FOI POSSIVEL ABRIR O ARQUIVO.\n");
  144. getchar();
  145. system("pause");
  146. menu();
  147. }
  148. do{
  149. system("cls");
  150. printf ("\t\t\t .----------------------. \n");
  151. printf ("\t\t\t | ** CADASTRO ** | \n");
  152. printf ("\t\t\t `----------------------' \n\n");
  153. printf("\n");
  154. printf("\t1 - Cadastrar novo jogador;\n");
  155. printf("\t2 - Voltar ao menu;\n");
  156. scanf("%d", &opcao);
  157. }while(opcao != 1 && opcao != 2 );
  158. system("cls");
  159. switch(opcao){
  160. case 1:
  161. printf ("\t\t\t .----------------------. \n");
  162. printf ("\t\t\t | ** JOGADORES ** | \n");
  163. printf ("\t\t\t `----------------------' \n\n");
  164. printf("Nome do Jogador 'X':\n");
  165. scanf("%s", &velha.player1);
  166. printf("Nome do jogador 'O':\n");
  167. scanf("%s",&velha.player2);
  168. registro();
  169. funcaojogo();
  170. case 2:
  171. menu();
  172. }
  173. }
  174. void cadastro3(){
  175. int opcao;
  176. players=fopen("players.txt","a");
  177. if (players == NULL) //verifica se teve algo escrito no arquivo, caso nao ele ira voltar pro menu
  178. {
  179. printf("NAO FOI POSSIVEL ABRIR O ARQUIVO.\n");
  180. getchar();
  181. system("pause");
  182. menu();
  183. }
  184. do{
  185. system("cls");
  186. printf ("\t\t\t .----------------------. \n");
  187. printf ("\t\t\t | ** CADASTRO ** | \n");
  188. printf ("\t\t\t `----------------------' \n\n");
  189. printf("\n");
  190.  
  191. printf("\t1 - Cadastrar novo jogador;\n");
  192. printf("\t2 - Voltar ao menu;\n");
  193. scanf("%d", &opcao);
  194. }while(opcao != 1 && opcao != 2 );
  195. system("cls");
  196. switch(opcao){
  197. case 1:
  198. printf ("\t\t\t .----------------------. \n");
  199. printf ("\t\t\t | ** JOGADORES ** | \n");
  200. printf ("\t\t\t `----------------------' \n\n");
  201. printf("Nome do Jogador 'X':\n");
  202. scanf("%s", &velha.player1);
  203. printf("Nome do jogador 'O':\n");
  204. scanf("%s",&velha.player2);
  205. printf("Nome do Jogador '':\n");
  206. scanf("%s", &velha.player3);
  207. registro();
  208. jogo1();
  209. case 2:
  210. menu();
  211. }
  212. }
  213. void funcaojogo () // funcao para rodar o jogo 3x3x3
  214. {
  215. ranking=fopen("ranking.txt","w");
  216.  
  217. char mat1[3][3];
  218. char mat2[3][3];
  219. char mat3[3][3];
  220. int q;
  221. int i=0,j=0,k=0,m=0,aux1,cont1=2,aux2;
  222. void andar3(){
  223. printf(" 3 andar\n");
  224. printf("\n %c| %c| %c\n",mat3[0][0],mat3[0][1],mat3[0][2]); // Printar o tabuleiro
  225. printf("___________\n"); // Printar o tabuleiro
  226. printf(" %c| %c| %c\n",mat3[1][0],mat3[1][1],mat3[1][2]); // Printar o tabuleiro
  227. printf("___________\n"); // Printar o tabuleiro
  228. printf(" %c| %c| %c\n",mat3[2][0],mat3[2][1],mat3[2][2]); // Printar o tabuleiro
  229. printf(" \n");
  230. }
  231. void andar2(){
  232. printf(" 2 andar\n");
  233. printf("\n %c| %c| %c\n",mat2[0][0],mat2[0][1],mat2[0][2]); // Printar o tabuleiro
  234. printf("___________\n"); // Printar o tabuleiro
  235. printf(" %c| %c| %c\n",mat2[1][0],mat2[1][1],mat2[1][2]); // Printar o tabuleiro
  236. printf("___________\n"); // Printar o tabuleiro
  237. printf(" %c| %c| %c\n",mat2[2][0],mat2[2][1],mat2[2][2]); // Printar o tabuleiro
  238. printf(" \n ");
  239. }
  240. void andar1(){
  241. printf(" 1 andar\n");
  242. printf("\n %c| %c| %c\n",mat1[0][0],mat1[0][1],mat1[0][2]); // Printar o tabuleiro
  243. printf("___________\n"); // Printar o tabuleiro
  244. printf(" %c| %c| %c\n",mat1[1][0],mat1[1][1],mat1[1][2]); // Printar o tabuleiro
  245. printf("___________\n"); // Printar o tabuleiro
  246. printf(" %c| %c| %c\n",mat1[2][0],mat1[2][1],mat1[2][2]); // Printar o tabuleiro
  247. printf(" \n \n \n ");
  248. printf(" \n\n");
  249. }
  250. for(i=0; i < 3; i++){ // preenchimento da matriz com ' '
  251. for(j=0; j < 3; j++){ //preenche todas a posição com ' '
  252. mat1[i][j]=' ';
  253. mat2[i][j]=' ';
  254. mat3[i][j]=' ';
  255. } // SEGUNDO LACO FOR
  256. } // PRIMEIRO LACO FOR
  257. andar3();//Printar TABULEIRO
  258. andar2();
  259. andar1();
  260. do // De onde o jogo de desenvolve
  261. {
  262. if (cont1 % 2 == 0) // SE FOR 0, q=88; SERÁ O JOGADOR 1, SE FOR q=79;, JOGADOR 2
  263. q=88;
  264. else
  265. q=79;
  266. do // Para escolher o andar
  267. {
  268. printf("Escolha o andar: 1,2 ou 3:\n");
  269. scanf("%d", &aux1);
  270. if(aux1==1){
  271. if((mat1[0][0]==88 || mat1[0][0]==79) && //primeiro andar preenchido
  272. (mat1[0][1]==88 || mat1[0][1]==79) && //primeiro andar preenchido
  273. (mat1[0][2]==88 || mat1[0][2]==79) && //primeiro andar preenchido
  274. (mat1[1][0]==88 || mat1[1][0]==79) && //primeiro andar preenchido
  275. (mat1[1][1]==88 || mat1[1][1]==79) && //primeiro andar preenchido
  276. (mat1[1][2]==88 || mat1[1][2]==79) && //primeiro andar preenchido
  277. (mat1[2][0]==88 || mat1[2][0]==79) && //primeiro andar preenchido
  278. (mat1[2][1]==88 || mat1[2][1]==79) && //primeiro andar preenchido
  279. (mat1[2][2]==88 || mat1[2][2]==79)) //primeiro andar preenchido
  280. { // chave do if
  281. do{
  282. printf("ANDAR 1 PREENCHIDO!\nEscolha o andar disponivel: 2 ou 3:\n");
  283. scanf("%d", &aux1);} while((aux1 != 2) && (aux1 != 3));
  284. }
  285. } //chave do if
  286. if(aux1==2){
  287. if((mat2[0][0]==88 || mat2[0][0]==79) && //Verificar segundo andar preenchido
  288. (mat2[0][1]==88 || mat2[0][1]==79) && //Verificar segundo andar preenchido
  289. (mat2[0][2]==88 || mat2[0][2]==79) && //Verificar segundo andar preenchido
  290. (mat2[1][0]==88 || mat2[1][0]==79) && //Verificar segundo andar preenchido
  291. (mat2[1][1]==88 || mat2[1][1]==79) && //Verificar segundo andar preenchido
  292. (mat2[1][2]==88 || mat2[1][2]==79) && //Verificar segundo andar preenchido
  293. (mat2[2][0]==88 || mat2[2][0]==79) && //Verificar segundo andar preenchido
  294. (mat2[2][1]==88 || mat2[2][1]==79) && //Verificar segundo andar preenchido
  295. (mat2[2][2]==88 || mat2[2][2]==79)) //Verificar segundo andar preenchido
  296. {
  297. do{
  298. printf("ANDAR 2 PREENCHIDO!\nEscolha o andar disponivel: 1 ou 3:\n");
  299. scanf("%d", &aux1);} while((aux1 != 1) && (aux1 != 3));
  300. }// chave do if
  301. }
  302. if(aux1==3){
  303. if((mat3[0][0]==88 || mat3[0][0]==79) && //Verificar terceiro andar preenchido
  304. (mat3[0][1]==88 || mat3[0][1]==79) && //Verificar terceiro andar preenchido
  305. (mat3[0][2]==88 || mat3[0][2]==79) && //Verificar terceiro andar preenchido
  306. (mat3[1][0]==88 || mat3[1][0]==79) && //Verificar terceiro andar preenchido
  307. (mat3[1][1]==88 || mat3[1][1]==79) && //Verificar terceiro andar preenchido
  308. (mat3[1][2]==88 || mat3[1][2]==79) && //Verificar terceiro andar preenchido
  309. (mat3[2][0]==88 || mat3[2][0]==79) && //Verificar terceiro andar preenchido
  310. (mat3[2][1]==88 || mat3[2][1]==79) && //Verificar terceiro andar preenchido
  311. (mat3[2][2]==88 || mat3[2][2]==79)) //Verificar terceiro andar preenchido
  312. {
  313. do{
  314. printf("ANDAR 3 PREENCHIDO!\nEscolha o andar disponivel: 1 ou 2:\n");
  315. scanf("%d", &aux1);} while((aux1 != 1) && (aux1 != 2));
  316. }//chave do if
  317. }
  318. } while((aux1 != 1) && (aux1 != 2) && (aux1 != 3)); //para Printar somente os andares disponíveis
  319. switch(aux1) // andar
  320. {
  321. case 1 :
  322. do
  323. {
  324. printf("Em qual linha e coluna vc deseja marcar:\n");
  325. printf("Linha: "); // Preencher o tabuleiro
  326. scanf("%d",&i); // Preencher o tabuleiro
  327. printf("Coluna: "); // Preencher o tabuleiro
  328. scanf("%d",&j); // Preencher o tabuleiro
  329. system("cls");
  330. } while((mat1[i-1][j-1]==88) || (mat1[i-1][j-1]==79)|| (i<1 || i>3) || (j<1 || j>3));// saber se tem x ou o marcado, se tiver, ele pede para digitar novamente
  331.  
  332. mat1[i-1][j-1]= q ; // para marcar x ou O na linha e colina escolhida
  333. if ((mat1[0][0]==88 && mat1[0][1]==88 && mat1[0][2]==88)|| // Teste para saber se marcou
  334. (mat1[1][0]==88 && mat1[1][1]==88 && mat1[1][2]==88)|| // Teste para saber se marcou
  335. (mat1[2][0]==88 && mat1[2][1]==88 && mat1[2][2]==88)|| // Teste para saber se marcou
  336. (mat1[0][0]==88 && mat1[1][0]==88 && mat1[2][0]==88)|| // Teste para saber se marcou
  337. (mat1[0][1]==88 && mat1[1][1]==88 && mat1[2][1]==88)|| // Teste para saber se marcou
  338. (mat1[0][2]==88 && mat1[1][2]==88 && mat1[2][2]==88)|| // Teste para saber se marcou
  339. (mat1[0][0]==88 && mat1[1][1]==88 && mat1[2][2]==88)|| // Teste para saber se marcou
  340. (mat1[0][2]==88 && mat1[1][1]==88 && mat1[2][0]==88)) // Teste para saber se marcou
  341. {
  342. velha.pont1++;
  343. }
  344. if ((mat1[0][0]==79 && mat1[0][1]==79 && mat1[0][2]==79)|| // Teste para saber se marcou
  345. (mat1[1][0]==79 && mat1[1][1]==79 && mat1[1][2]==79)|| // Teste para saber se marcou
  346. (mat1[2][0]==79 && mat1[2][1]==79 && mat1[2][2]==79)|| // Teste para saber se marcou
  347. (mat1[0][0]==79 && mat1[1][0]==79 && mat1[2][0]==79)|| // Teste para saber se marcou
  348. (mat1[0][1]==79 && mat1[1][1]==79 && mat1[2][1]==79)|| // Teste para saber se marcou
  349. (mat1[0][2]==79 && mat1[1][2]==79 && mat1[2][2]==79)|| // Teste para saber se marcou
  350. (mat1[0][0]==79 && mat1[1][1]==79 && mat1[2][2]==79)|| // Teste para saber se marcou
  351. (mat1[0][2]==79 && mat1[1][1]==79 && mat1[2][0]==79)) // Teste para saber se marcou
  352. {
  353. velha.pont2++;
  354. }
  355. break; // break do caso 1
  356. case 2 :
  357. do
  358. {
  359. printf("Em qual linha e coluna vc deseja marcar:\n");
  360. printf("Linha: "); // Preencher o tabuleiro
  361. scanf("%d",&i); // Preencher o tabuleiro
  362. printf("Coluna: "); // Preencher o tabuleiro
  363. scanf("%d",&j); // Preencher o tabuleiro
  364. system("cls");
  365. } while((mat2[i-1][j-1]==88) || (mat2[i-1][j-1]==79)|| (i<1 || i>3) || (j<1 || j>3));// saber se tem x ou o marcado, se tiver, ele pede para digitar novamente
  366. mat2[i-1][j-1]= q ; // para marcar x ou O na linha e colina escolhida
  367. if ((mat2[0][0]==88 && mat2[0][1]==88 && mat2[0][2]==88)|| // Teste para saber se marcou
  368. (mat2[1][0]==88 && mat2[1][1]==88 && mat2[1][2]==88)|| // Teste para saber se marcou
  369. (mat2[2][0]==88 && mat2[2][1]==88 && mat2[2][2]==88)|| // Teste para saber se marcou
  370. (mat2[0][0]==88 && mat2[1][0]==88 && mat2[2][0]==88)|| // Teste para saber se marcou
  371. (mat2[0][1]==88 && mat2[1][1]==88 && mat2[2][1]==88)|| // Teste para saber se marcou
  372. (mat2[0][2]==88 && mat2[1][2]==88 && mat2[2][2]==88)|| // Teste para saber se marcou
  373. (mat2[0][0]==88 && mat2[1][1]==88 && mat2[2][2]==88)|| // Teste para saber se marcou
  374. (mat2[0][2]==88 && mat2[1][1]==88 && mat2[2][0]==88)) // Teste para saber se marcou
  375. {
  376. velha.pont1++;
  377. }
  378. if ((mat2[0][0]==79 && mat2[0][1]==79 && mat2[0][2]==79)|| // Teste para saber se marcou
  379. (mat2[1][0]==79 && mat2[1][1]==79 && mat2[1][2]==79)|| // Teste para saber se marcou
  380. (mat2[2][0]==79 && mat2[2][1]==79 && mat2[2][2]==79)|| // Teste para saber se marcou
  381. (mat2[0][0]==79 && mat2[1][0]==79 && mat2[2][0]==79)|| // Teste para saber se marcou
  382. (mat2[0][1]==79 && mat2[1][1]==79 && mat2[2][1]==79)|| // Teste para saber se marcou
  383. (mat2[0][2]==79 && mat2[1][2]==79 && mat2[2][2]==79)|| // Teste para saber se marcou
  384. (mat2[0][0]==79 && mat2[1][1]==79 && mat2[2][2]==79)|| // Teste para saber se marcou
  385. (mat2[0][2]==79 && mat2[1][1]==79 && mat2[2][0]==79)) // Teste para saber se marcou
  386. {
  387. velha.pont2++;
  388. }
  389. break;// break do caso 2
  390. case 3 :
  391. do
  392. {
  393. printf("Em qual linha e coluna vc deseja marcar.\n");
  394. printf("Linha: "); // Preencher o tabuleiro
  395. scanf("%d",&i); // Preencher o tabuleiro
  396. printf("Coluna: "); // Preencher o tabuleiro
  397. scanf("%d",&j); // Preencher o tabuleiro
  398. system("cls");
  399. } while((mat3[i-1][j-1]==88) || (mat3[i-1][j-1]==79)|| (i<1 || i>3) || (j<1 || j>3)); // saber se tem x ou o marcado, se tiver, ele pede para digitar novamente
  400. mat3[i-1][j-1]= q ; // para marcar x ou O na linha e colina escolhida
  401. if((mat3[0][0]==88 && mat3[0][1]==88 && mat3[0][2]==88)|| // Teste para saber se marcou
  402. (mat3[1][0]==88 && mat3[1][1]==88 && mat3[1][2]==88)|| // Teste para saber se marcou
  403. (mat3[2][0]==88 && mat3[2][1]==88 && mat3[2][2]==88)|| // Teste para saber se marcou
  404. (mat3[0][0]==88 && mat3[1][0]==88 && mat3[2][0]==88)|| // Teste para saber se marcou
  405. (mat3[0][1]==88 && mat3[1][1]==88 && mat3[2][1]==88)|| // Teste para saber se marcou
  406. (mat3[0][2]==88 && mat3[1][2]==88 && mat3[2][2]==88)|| // Teste para saber se marcou
  407. (mat3[0][0]==88 && mat3[1][1]==88 && mat3[2][2]==88)|| // Teste para saber se marcou
  408. (mat3[0][2]==88 && mat3[1][1]==88 && mat3[2][0]==88)) // Teste para saber se marcou
  409. {
  410. velha.pont1++;
  411. }
  412. if ((mat3[0][0]==79 && mat3[0][1]==79 && mat3[0][2]==79)|| // Teste para saber se marcou
  413. (mat3[1][0]==79 && mat3[1][1]==79 && mat3[1][2]==79)|| // Teste para saber se marcou
  414. (mat3[2][0]==79 && mat3[2][1]==79 && mat3[2][2]==79)|| // Teste para saber se marcou
  415. (mat3[0][0]==79 && mat3[1][0]==79 && mat3[2][0]==79)|| // Teste para saber se marcou
  416. (mat3[0][1]==79 && mat3[1][1]==79 && mat3[2][1]==79)|| // Teste para saber se marcou
  417. (mat3[0][2]==79 && mat3[1][2]==79 && mat3[2][2]==79)|| // Teste para saber se marcou
  418. (mat3[0][0]==79 && mat3[1][1]==79 && mat3[2][2]==79)|| // Teste para saber se marcou
  419. (mat3[0][2]==79 && mat3[1][1]==79 && mat3[2][0]==79)) // Teste para saber se marcou
  420. {
  421. velha.pont2++;
  422. }
  423. break; // break do caso 3
  424. } // chave do switch
  425. if ((mat3[2][0]==88 && mat2[2][0]==88 && mat1[2][0]==88)|| // TESTE PARA SABER SE MARCOU PARTE 3D
  426. (mat3[2][1]==88 && mat2[2][1]==88 && mat1[2][1]==88)|| // TESTE PARA SABER SE MARCOU PARTE 3D
  427. (mat3[2][2]==88 && mat2[2][2]==88 && mat1[2][2]==88)|| // TESTE PARA SABER SE MARCOU PARTE 3D
  428. (mat3[0][1]==88 && mat2[0][1]==88 && mat1[0][1]==88)|| // TESTE PARA SABER SE MARCOU PARTE 3D
  429. (mat3[1][1]==88 && mat2[1][1]==88 && mat1[1][1]==88)|| // TESTE PARA SABER SE MARCOU PARTE 3D
  430. (mat3[1][2]==88 && mat2[1][2]==88 && mat1[1][2]==88)|| // TESTE PARA SABER SE MARCOU PARTE 3D
  431. (mat3[0][0]==88 && mat2[0][0]==88 && mat1[0][0]==88)|| // TESTE PARA SABER SE MARCOU PARTE 3D
  432. (mat3[0][1]==88 && mat2[0][1]==88 && mat1[0][1]==88)|| // TESTE PARA SABER SE MARCOU PARTE 3D
  433. (mat3[2][0]==88 && mat2[2][1]==88 && mat1[2][2]==88)|| // diagonal DA FATIA VERTICAL 3E
  434. (mat3[2][2]==88 && mat2[2][1]==88 && mat1[2][0]==88)|| // diagonal DA FATIA VERTICAL 3E
  435. (mat3[1][0]==88 && mat2[1][1]==88 && mat1[1][2]==88)|| // diagonal DA FATIA VERTICAL 3E
  436. (mat3[1][2]==88 && mat2[1][1]==88 && mat1[1][0]==88)|| // diagonal DA FATIA VERTICAL 3E
  437. (mat3[0][0]==88 && mat2[0][1]==88 && mat1[0][2]==88)|| // diagonal DA FATIA VERTICAL 3E
  438. (mat3[0][2]==88 && mat2[0][1]==88 && mat1[0][0]==88)|| // diagonal DA FATIA VERTICAL 3E
  439. (mat3[0][0]==88 && mat2[1][1]==88 && mat1[2][2]==88)|| // diagonal CUBO
  440. (mat3[0][2]==88 && mat2[1][1]==88 && mat1[2][0]==88)|| // diagonal CUBO
  441. (mat3[2][0]==88 && mat2[1][1]==88 && mat1[0][2]==88)|| // diagonal CUBO
  442. (mat3[2][2]==88 && mat2[1][1]==88 && mat1[0][0]==88)|| // diagonal CUBO
  443. (mat3[0][2]==88 && mat2[0][2]==88 && mat1[0][2]==88))
  444. {
  445. velha.pont1++;
  446. }
  447. if( (mat3[2][0]==79 && mat2[2][0]==79 && mat1[2][0]==79)|| // TESTE PARA SABER SE MARCOU PARTE 3D
  448. (mat3[2][1]==79 && mat2[2][1]==79 && mat1[2][1]==79)|| // TESTE PARA SABER SE MARCOU PARTE 3D
  449. (mat3[2][2]==79 && mat2[2][2]==79 && mat1[2][2]==79)|| // TESTE PARA SABER SE MARCOU PARTE 3D
  450. (mat3[0][1]==79 && mat2[0][1]==79 && mat1[0][1]==79)|| // TESTE PARA SABER SE MARCOU PARTE 3D
  451. (mat3[1][1]==79 && mat2[1][1]==79 && mat1[1][1]==79)|| // TESTE PARA SABER SE MARCOU PARTE 3D
  452. (mat3[1][2]==79 && mat2[1][2]==79 && mat1[1][2]==79)|| // TESTE PARA SABER SE MARCOU PARTE 3D
  453. (mat3[0][0]==79 && mat2[0][0]==79 && mat1[0][0]==79)|| // TESTE PARA SABER SE MARCOU PARTE 3D
  454. (mat3[0][1]==79 && mat2[0][1]==79 && mat1[0][1]==79)|| // TESTE PARA SABER SE MARCOU PARTE 3D
  455. (mat3[2][0]==79 && mat2[2][1]==79 && mat1[2][2]==79)|| // diagonal DA FATIA VERTICAL 3E
  456. (mat3[2][2]==79 && mat2[2][1]==79 && mat1[2][0]==79)|| // diagonal DA FATIA VERTICAL 3E
  457. (mat3[1][0]==79 && mat2[1][1]==79 && mat1[1][2]==79)|| // diagonal DA FATIA VERTICAL 3E
  458. (mat3[1][2]==79 && mat2[1][1]==79 && mat1[1][0]==79)|| // diagonal DA FATIA VERTICAL 3E
  459. (mat3[0][0]==79 && mat2[0][1]==79 && mat1[0][2]==79)|| // diagonal DA FATIA VERTICAL 3E
  460. (mat3[0][2]==79 && mat2[0][1]==79 && mat1[0][0]==79)|| // diagonal DA FATIA VERTICAL 3E
  461. (mat3[0][0]==79 && mat2[1][1]==79 && mat1[2][2]==79)|| // diagonal CUBO
  462. (mat3[0][2]==79 && mat2[1][1]==79 && mat1[2][0]==79)|| // diagonal CUBO
  463. (mat3[2][0]==79 && mat2[1][1]==79 && mat1[0][2]==79)|| // diagonal CUBO
  464. (mat3[2][2]==79 && mat2[1][1]==79 && mat1[0][0]==79)|| // diagonal CUBO
  465. (mat3[0][2]==79 && mat2[0][2]==79 && mat1[0][2]==79))
  466. {
  467. velha.pont2++;
  468. }
  469. andar3();
  470. andar2();
  471. andar1();
  472. cont1++; // PRINCIPAL CONTADOR, ONDE O JOGO RODA
  473. } // } do 'DO' PRINCIPAL
  474. while (cont1<29); // O JOGO RODA POR CAUSA DESSE WHILE
  475. if(cont1==27)
  476. printf("\n\nEMPATE\n\n");
  477. if(velha.pont1 > velha.pont2)
  478. printf("Jogador 1 venceu!\n\n");
  479. else
  480. printf("Jogador 2 venceu!\n\n");
  481.  
  482. return continua();
  483.  
  484. } // ultima chave
  485. void jogo() // funcao para rodar o jogo
  486. {
  487. char matn1[4][4];
  488. char matn2[4][4];
  489. char matn3[4][4];
  490. char matn4[4][4];
  491. int q;
  492. int i=0,j=0,k=0,m=0,aux1,cont1=2,aux2,contx=0,conty=0;
  493.  
  494. int andarn4(){
  495. printf(" 4 andar\n");
  496. printf("\n %c| %c| %c| %c\n",matn4[0][0],matn4[0][1],matn4[0][2], matn4[0][3]); //Printar o tabuleiro
  497. printf("___________\n"); //Printar o tabuleiro
  498. printf(" %c| %c| %c| %c\n",matn4[1][0],matn4[1][1],matn4[1][2], matn4[1][3]); //Printar o tabuleiro
  499. printf("___________\n"); //Printar o tabuleiro
  500. printf(" %c| %c| %c| %c\n",matn4[2][0],matn4[2][1],matn4[2][2], matn4[2][3]); //Printar o tabuleiro
  501. printf("___________\n"); //Printar o tabuleiro
  502. printf(" %c| %c| %c| %c\n",matn4[3][0],matn4[3][1],matn4[3][2], matn4[3][3]); //Printar o tabuleiro
  503. printf(" \n");
  504. }
  505. int andarn3(){
  506. printf(" 3 andar\n");
  507. printf("\n %c| %c| %c| %c\n",matn3[0][0],matn3[0][1],matn3[0][2], matn3[0][3]); //Printar o tabuleiro
  508. printf("___________\n"); //Printar o tabuleiro
  509. printf(" %c| %c| %c| %c\n",matn3[1][0],matn3[1][1],matn3[1][2], matn3[1][3]); //Printar o tabuleiro
  510. printf("___________\n"); //Printar o tabuleiro
  511. printf(" %c| %c| %c| %c\n",matn3[2][0],matn3[2][1],matn3[2][2], matn3[2][3]); //Printar o tabuleiro
  512. printf("___________\n"); //Printar o tabuleiro
  513. printf(" %c| %c| %c| %c\n",matn3[3][0],matn3[3][1],matn3[3][2], matn3[3][3]); //Printar o tabuleiro
  514. printf(" \n");
  515. }
  516. int andarn2 (){
  517. printf(" 2 andar\n");
  518. printf("\n %c| %c| %c| %c\n",matn2[0][0],matn2[0][1],matn2[0][2], matn2[0][3]); //Printar o tabuleiro
  519. printf("___________\n"); //Printar o tabuleiro
  520. printf(" %c| %c| %c| %c\n",matn2[1][0],matn2[1][1],matn2[1][2], matn2[1][3]); //Printar o tabuleiro
  521. printf("___________\n"); //Printar o tabuleiro
  522. printf(" %c| %c| %c| %c\n",matn2[2][0],matn2[2][1],matn2[2][2], matn2[2][3]); //Printar o tabuleiro
  523. printf("___________\n"); //Printar o tabuleiro
  524. printf(" %c| %c| %c| %c\n",matn2[3][0],matn2[3][1],matn2[3][2], matn2[3][3]); //Printar o tabuleiro
  525. printf(" \n ");
  526. }
  527. int andarn1(){
  528. printf(" 1 andar\n");
  529. printf("\n %c| %c| %c| %c\n",matn1[0][0],matn1[0][1],matn1[0][2], matn1[0][3]); //Printar o tabuleiro
  530. printf("___________\n"); //Printar o tabuleiro
  531. printf(" %c| %c| %c| %c\n",matn1[1][0],matn1[1][1],matn1[1][2], matn1[1][3]); //Printar o tabuleiro
  532. printf("___________\n"); //Printar o tabuleiro
  533. printf(" %c| %c| %c| %c\n",matn1[2][0],matn1[2][1],matn1[2][2], matn1[2][3]); //Printar o tabuleiro
  534. printf("___________\n"); //Printar o tabuleiro
  535. printf(" %c| %c| %c| %c\n",matn1[3][0],matn1[3][1],matn1[3][2], matn1[3][3]); //Printar o tabuleiro
  536. printf(" \n \n \n ");
  537. printf(" \n\n");
  538. }
  539. for(i=0; i <=3; i++){ // preenchimento da matriz com ' '
  540. for(j=0; j <= 3 ; j++){ //preenche todas a posição com ' '
  541. matn1[i][j]=' ';
  542. matn2[i][j]=' ';
  543. matn3[i][j]=' ';
  544. matn4[i][j]=' ';
  545. } // SEGUNDO LACO FOR
  546. } // PRIMEIRO LACO FOR
  547. andarn4();
  548. andarn3();
  549. andarn2();
  550. andarn1();
  551. do
  552. {
  553. if (cont1 % 2 == 0) // SE FOR 0, q=88; SERÁ O JOGADOR 1, SE FOR q=79;, JOGADOR 2
  554. q=88;
  555. else
  556. q=79;
  557. do
  558. {
  559. printf("Escolha o andar: 1, 2, 3 ou 4:\n");
  560. scanf("%d", &aux1);
  561. if(aux1==1){ //Escolher o Andar
  562. if ((matn1[0][0]==88 || matn1[0][0]==79) && (matn1[0][1]==88 || matn1[0][1]==79) && //Verificar se o andar está preenchido
  563. (matn1[0][2]==88 || matn1[0][2]==79) && (matn1[0][3]==88 || matn1[0][3]==79) && //Verificar se o andar está preenchido
  564. (matn1[1][0]==88 || matn1[1][0]==79) && (matn1[1][1]==88 || matn1[1][1]==79) && //Verificar se o andar está preenchido
  565. (matn1[1][2]==88 || matn1[1][2]==79) && (matn1[1][3]==88 || matn1[1][3]==79) && //Verificar se o andar está preenchido
  566. (matn1[2][0]==88 || matn1[2][0]==79) && (matn1[2][1]==88 || matn1[2][1]==79) && //Verificar se o andar está preenchido
  567. (matn1[2][2]==88 || matn1[2][2]==79) && (matn1[2][3]==88 || matn1[2][3]==79) && //Verificar se o andar está preenchido
  568. (matn1[3][0]==88 || matn1[3][0]==79) && (matn1[3][1]==88 || matn1[3][1]==79) && //Verificar se o andar está preenchido
  569. (matn1[3][2]==88 || matn1[3][2]==79) && (matn1[3][3]==88 || matn1[3][3]==79)) //Verificar se o andar está preenchido
  570. {
  571. do{
  572. printf("ANDAR 1 PREENCHIDO!\nEscolha o andar disponivel: '2','3' ou '4':\n");
  573. scanf("%d", &aux1);} while((aux1 != 2) && (aux1 != 3) && (aux1 != 4));
  574. }
  575. }
  576. if(aux1==2){
  577. if ((matn2[0][0]==88 || matn2[0][0]==79) && (matn2[0][1]==88 || matn2[0][1]==79) && //Verificar se o andar está preenchido
  578. (matn2[0][2]==88 || matn2[0][2]==79) && (matn2[0][3]==88 || matn2[0][3]==79) &&
  579. (matn2[1][0]==88 || matn2[1][0]==79) && (matn2[1][1]==88 || matn2[1][1]==79) &&
  580. (matn2[1][2]==88 || matn2[1][2]==79) && (matn2[1][3]==88 || matn2[1][3]==79) &&
  581. (matn2[2][0]==88 || matn2[2][0]==79) && (matn2[2][1]==88 || matn2[2][1]==79) &&
  582. (matn2[2][2]==88 || matn2[2][2]==79) && (matn2[2][3]==88 || matn2[2][3]==79) &&
  583. (matn2[3][0]==88 || matn2[3][0]==79) && (matn2[3][1]==88 || matn2[3][1]==79) &&
  584. (matn2[3][2]==88 || matn2[3][2]==79) && (matn2[3][3]==88 || matn2[3][3]==79))
  585. {
  586. do{
  587. system("cls");
  588. printf("ANDAR 2 PREENCHIDO!\nEscolha o andar disponivel: '1','3' ou '4':\n");
  589. scanf("%d", &aux1);} while((aux1 != 1) && (aux1 != 3) && (aux1 != 4));
  590. }
  591. }
  592. if(aux1==3){
  593. if ((matn3[0][0]==88 || matn3[0][0]==79) && (matn3[0][1]==88 || matn3[0][1]==79) && //Verificar se o andar está preenchido
  594. (matn3[0][2]==88 || matn3[0][2]==79) && (matn3[0][3]==88 || matn3[0][3]==79) &&
  595. (matn3[1][0]==88 || matn3[1][0]==79) && (matn3[1][1]==88 || matn3[1][1]==79) &&
  596. (matn3[1][2]==88 || matn3[1][2]==79) && (matn3[1][3]==88 || matn3[1][3]==79) &&
  597. (matn3[2][0]==88 || matn3[2][0]==79) && (matn3[2][1]==88 || matn3[2][1]==79) &&
  598. (matn3[2][2]==88 || matn3[2][2]==79) && (matn3[2][3]==88 || matn3[2][3]==79) &&
  599. (matn3[3][0]==88 || matn3[3][0]==79) && (matn3[3][1]==88 || matn3[3][1]==79) &&
  600. (matn3[3][2]==88 || matn3[3][2]==79) && (matn3[3][3]==88 || matn3[3][3]==79))
  601. {
  602. do{
  603. system("cls");
  604. printf("ANDAR 3 PREENCHIDO!\nEscolha o andar disponivel: '1','2' ou '4':\n");
  605. scanf("%d", &aux1);} while((aux1 != 1) && (aux1 != 2) && (aux1 != 4));
  606. }
  607. }
  608. if(aux1==4){
  609. if ((matn4[0][0]==88 || matn4[0][0]==79) && (matn4[0][1]==88 || matn4[0][1]==79) && //Verificar se o andar está preenchido
  610. (matn4[0][2]==88 || matn4[0][2]==79) && (matn4[0][3]==88 || matn4[0][3]==79) &&
  611. (matn4[1][0]==88 || matn4[1][0]==79) && (matn4[1][1]==88 || matn4[1][1]==79) &&
  612. (matn4[1][2]==88 || matn4[1][2]==79) && (matn4[1][3]==88 || matn4[1][3]==79) &&
  613. (matn4[2][0]==88 || matn4[2][0]==79) && (matn4[2][1]==88 || matn4[2][1]==79) &&
  614. (matn4[2][2]==88 || matn4[2][2]==79) && (matn4[2][3]==88 || matn4[2][3]==79) &&
  615. (matn4[3][0]==88 || matn4[3][0]==79) && (matn4[3][1]==88 || matn4[3][1]==79) &&
  616. (matn4[3][2]==88 || matn4[3][2]==79) && (matn4[3][3]==88 || matn4[3][3]==79))
  617. {
  618. do{
  619. system("cls");
  620. printf("ANDAR 4 PREENCHIDO!\nEscolha o andar disponivel: '1','2' ou '3':\n");
  621. scanf("%d", &aux1);} while((aux1 != 1) && (aux1 != 2) && (aux1 != 3));
  622. }
  623. }
  624. } while((aux1 != 1) && (aux1 != 2) && (aux1 != 3) && (aux1 != 4)); //Enquanto o usuario não digitar os andares 1,2,3 e 4, ele continua pedindo
  625. switch(aux1) // jogo
  626. {
  627.  
  628. case 1 :
  629. do
  630. {
  631. printf("Em qual linha e coluna vc deseja marcar.\n");
  632. printf("Linha: "); // Preencher o tabuleiro
  633. scanf("%d",&i); // Preencher o tabuleiro
  634. printf("Coluna: "); // Preencher o tabuleiro
  635. scanf("%d",&j); // Preencher o tabuleiro
  636. system("cls");
  637. }
  638. while((matn1[i-1][j-1]==88) || (matn1[i-1][j-1]==79)|| (i<1 || i>4) || (j<1 || j>4));// saber se tem x ou o marcado, se tiver, ele pede para digitar novamente
  639.  
  640. matn1[i-1][j-1]= q ;
  641.  
  642. // condicoes matriz n1
  643. if((matn1[0][0]== 88 && matn1[0][1]== 88 && matn1[0][2]== 88 && matn1[0][3]== 88 )|| // linha // Verificar se ganhou
  644. (matn1[1][0]== 88 && matn1[1][1]== 88 && matn1[1][2]== 88 && matn1[1][3]== 88 )|| // linha
  645. (matn1[2][0]== 88 && matn1[2][1]== 88 && matn1[2][2]== 88 && matn1[2][3]== 88 )|| // linha
  646. (matn1[3][0]== 88 && matn1[3][1]== 88 && matn1[3][2]== 88 && matn1[3][3]== 88 )|| // linha
  647. (matn1[0][0]== 88 && matn1[1][0]== 88 && matn1[2][0]== 88 && matn1[3][0]== 88 )|| // coluna
  648. (matn1[0][1]== 88 && matn1[1][1]== 88 && matn1[2][1]== 88 && matn1[3][1]== 88 )|| // coluna
  649. (matn1[0][2]== 88 && matn1[1][2]== 88 && matn1[2][2]== 88 && matn1[3][2]== 88 )|| // coluna
  650. (matn1[0][3]== 88 && matn1[1][3]== 88 && matn1[2][3]== 88 && matn1[3][3]== 88 )|| // coluna
  651. (matn1[0][0]== 88 && matn1[1][1]== 88 && matn1[2][2]== 88 && matn1[3][3]== 88 )|| // diagonal
  652. (matn1[3][0]== 88 && matn1[2][1]== 88 && matn1[1][2]== 88 && matn1[0][3]== 88 )) // diagonal
  653. {
  654. system("cls");
  655. printf("*********************************** \n");
  656. printf("* Parabens player 1 voce venceu!!!*\n");
  657. printf("***********************************\n\n");
  658. velha.pont1++;
  659. return continua();
  660. }
  661. if((matn1[0][0]== 79 && matn1[0][1]== 79 && matn1[0][2]== 79 && matn1[0][3]== 79 )|| // linha // Verificar se ganhou
  662. (matn1[1][0]== 79 && matn1[1][1]== 79 && matn1[1][2]== 79 && matn1[1][3]== 79 )|| // linha
  663. (matn1[2][0]== 79 && matn1[2][1]== 79 && matn1[2][2]== 79 && matn1[2][3]== 79 )|| // linha
  664. (matn1[3][0]== 79 && matn1[3][1]== 79 && matn1[3][2]== 79 && matn1[3][3]== 79 )|| // linha
  665. (matn1[0][0]== 79 && matn1[1][0]== 79 && matn1[2][0]== 79 && matn1[3][0]== 79 )|| // coluna
  666. (matn1[0][1]== 79 && matn1[1][1]== 79 && matn1[2][1]== 79 && matn1[3][1]== 79 )|| // coluna
  667. (matn1[0][2]== 79 && matn1[1][2]== 79 && matn1[2][2]== 79 && matn1[3][2]== 79 )|| // coluna
  668. (matn1[0][3]== 79 && matn1[1][3]== 79 && matn1[2][3]== 79 && matn1[3][3]== 79 )|| // coluna
  669. (matn1[0][0]== 79 && matn1[1][1]== 79 && matn1[2][2]== 79 && matn1[3][3]== 79 )|| // diagonal
  670. (matn1[3][0]== 79 && matn1[2][1]== 79 && matn1[1][2]== 79 && matn1[0][3]== 79 )) // diagonal
  671. {
  672. system("cls");
  673. printf("*********************************** \n");
  674. printf("* Parabens player 2 voce venceu!!!*\n");
  675. printf("***********************************\n\n");
  676. velha.pont2++;
  677. return continua();
  678. }
  679. if(cont1==68){
  680. printf("\n\nEMPATE\n\n");
  681. return continua();}
  682. break; // break do caso 1
  683. case 2 :
  684. do
  685. {
  686. printf("Em qual linha e coluna vc deseja marcar:\n");
  687. printf("Linha: "); // Preencher o tabuleiro
  688. scanf("%d",&i); // Preencher o tabuleiro
  689. printf("Coluna: "); // Preencher o tabuleiro
  690. scanf("%d",&j); // Preencher o tabuleiro
  691. system("cls");
  692. }
  693. while((matn2[i-1][j-1]==88) || (matn2[i-1][j-1]==79)|| (i<1 || i>4) || (j<1 || j>4));// saber se tem x ou o marcado, se tiver, ele pede para digitar novamente
  694. matn2[i-1][j-1]= q ;
  695. if((matn2[0][0]== 88 && matn2[0][1]== 88 && matn2[0][2]== 88 && matn2[0][3]== 88 )|| // linha // Verificar se ganhou
  696. (matn2[1][0]== 88 && matn2[1][1]== 88 && matn2[1][2]== 88 && matn2[1][3]== 88 )|| // linha
  697. (matn2[2][0]== 88 && matn2[2][1]== 88 && matn2[2][2]== 88 && matn2[2][3]== 88 )|| // linha
  698. (matn2[3][0]== 88 && matn2[3][1]== 88 && matn2[3][2]== 88 && matn2[3][3]== 88 )|| // linha
  699. (matn2[0][0]== 88 && matn2[1][0]== 88 && matn2[2][0]== 88 && matn2[3][0]== 88 )|| // coluna
  700. (matn2[0][1]== 88 && matn2[1][1]== 88 && matn2[2][1]== 88 && matn2[3][1]== 88 )|| // coluna
  701. (matn2[0][2]== 88 && matn2[1][2]== 88 && matn2[2][2]== 88 && matn2[3][2]== 88 )|| // coluna
  702. (matn2[0][3]== 88 && matn2[1][3]== 88 && matn2[2][3]== 88 && matn2[3][3]== 88 )|| // coluna
  703. (matn2[0][0]== 88 && matn2[1][1]== 88 && matn2[2][2]== 88 && matn2[3][3]== 88 )|| // diagonal
  704. (matn2[3][0]== 88 && matn2[2][1]== 88 && matn2[1][2]== 88 && matn2[0][3]== 88 )) // diagonal
  705. {
  706. system("cls");
  707. printf("*********************************** \n");
  708. printf("* Parabens player 1 voce venceu!!!*\n");
  709. printf("***********************************\n\n");
  710. velha.pont1++;
  711. return continua();
  712. }
  713. if((matn2[0][0]== 79 && matn2[0][1]== 79 && matn2[0][2]== 79 && matn2[0][3]== 79 )|| // linha // Verificar se ganhou
  714. (matn2[1][0]== 79 && matn2[1][1]== 79 && matn2[1][2]== 79 && matn2[1][3]== 79 )|| // linha
  715. (matn2[2][0]== 79 && matn2[2][1]== 79 && matn2[2][2]== 79 && matn2[2][3]== 79 )|| // linha
  716. (matn2[3][0]== 79 && matn2[3][1]== 79 && matn2[3][2]== 79 && matn2[3][3]== 79 )|| // linha
  717. (matn2[0][0]== 79 && matn2[1][0]== 79 && matn2[2][0]== 79 && matn2[3][0]== 79 )|| // coluna
  718. (matn2[0][1]== 79 && matn2[1][1]== 79 && matn2[2][1]== 79 && matn2[3][1]== 79 )|| // coluna
  719. (matn2[0][2]== 79 && matn2[1][2]== 79 && matn2[2][2]== 79 && matn2[3][2]== 79 )|| // coluna
  720. (matn2[0][3]== 79 && matn2[1][3]== 79 && matn2[2][3]== 79 && matn2[3][3]== 79 )|| // coluna
  721. (matn2[0][0]== 79 && matn2[1][1]== 79 && matn2[2][2]== 79 && matn2[3][3]== 79 )|| // diagonal
  722. (matn2[3][0]== 79 && matn2[2][1]== 79 && matn2[1][2]== 79 && matn2[0][3]== 79 )) // diagonal
  723. {
  724. system("cls");
  725. printf("*********************************** \n");
  726. printf("* Parabens player 2 voce venceu!!!*\n");
  727. printf("***********************************\n\n");
  728. velha.pont2++;
  729. return continua();
  730. }
  731. if(cont1==68){
  732. printf("\n\nEMPATE\n\n");
  733. return continua();}
  734. break;// break do caso 2
  735. case 3 :
  736. do
  737. {
  738. printf("Em qual linha e coluna vc deseja marcar.\n");
  739. printf("Linha: "); // Preencher o tabuleiro
  740. scanf("%d",&i); // Preencher o tabuleiro
  741. printf("Coluna: "); // Preencher o tabuleiro
  742. scanf("%d",&j); // Preencher o tabuleiro
  743. system("cls");
  744. }
  745. while((matn3[i-1][j-1]==88) || (matn3[i-1][j-1]==79)|| (i<1 || i>4) || (j<1 || j>4)); // saber se tem x ou o marcado, se tiver, ele pede para digitar novamente
  746. matn3[i-1][j-1]= q ;
  747.  
  748. // condicoes matriz n3
  749.  
  750. if((matn3[0][0]== 88 && matn3[0][1]== 88 && matn3[0][2]== 88 && matn3[0][3]== 88 )|| // linha // Verificar se ganhou
  751. (matn3[1][0]== 88 && matn3[1][1]== 88 && matn3[1][2]== 88 && matn3[1][3]== 88 )|| // linha
  752. (matn3[2][0]== 88 && matn3[2][1]== 88 && matn3[2][2]== 88 && matn3[2][3]== 88 )|| // linha
  753. (matn3[3][0]== 88 && matn3[3][1]== 88 && matn3[3][2]== 88 && matn3[3][3]== 88 )|| // linha
  754. (matn3[0][0]== 88 && matn3[1][0]== 88 && matn3[2][0]== 88 && matn3[3][0]== 88 )|| // coluna
  755. (matn3[0][1]== 88 && matn3[1][1]== 88 && matn3[2][1]== 88 && matn3[3][1]== 88 )|| // coluna
  756. (matn3[0][2]== 88 && matn3[1][2]== 88 && matn3[2][2]== 88 && matn3[3][2]== 88 )|| // coluna
  757. (matn3[0][3]== 88 && matn3[1][3]== 88 && matn3[2][3]== 88 && matn3[3][3]== 88 )|| // coluna
  758. (matn3[0][0]== 88 && matn3[1][1]== 88 && matn3[2][2]== 88 && matn3[3][3]== 88 )|| // diagonal
  759. (matn3[3][0]== 88 && matn3[2][1]== 88 && matn3[1][2]== 88 && matn3[0][3]== 88 )) // diagonal
  760. {
  761. system("cls");
  762. printf("\t\t\t\t*********************************** \n");
  763. printf("\t\t\t\t* Parabens player 1 voce venceu!!!*\n");
  764. printf("\t\t\t\t***********************************\n\n");
  765. velha.pont1++;
  766. return continua();
  767. }
  768. if ((matn3[0][0]== 79 && matn3[0][1]== 79 && matn3[0][2]== 79 && matn3[0][3]== 79 )|| // linha
  769. (matn3[1][0]== 79 && matn3[1][1]== 79 && matn3[1][2]== 79 && matn3[1][3]== 79 )|| // linha
  770. (matn3[2][0]== 79 && matn3[2][1]== 79 && matn3[2][2]== 79 && matn3[2][3]== 79 )|| // linha
  771. (matn3[3][0]== 79 && matn3[3][1]== 79 && matn3[3][2]== 79 && matn3[3][3]== 79 )|| // linha
  772. (matn3[0][0]== 79 && matn3[1][0]== 79 && matn3[2][0]== 79 && matn3[3][0]== 79 )|| // coluna
  773. (matn3[0][1]== 79 && matn3[1][1]== 79 && matn3[2][1]== 79 && matn3[3][1]== 79 )|| // coluna
  774. (matn3[0][2]== 79 && matn3[1][2]== 79 && matn3[2][2]== 79 && matn3[3][2]== 79 )|| // coluna
  775. (matn3[0][3]== 79 && matn3[1][3]== 79 && matn3[2][3]== 79 && matn3[3][3]== 79 )|| // coluna
  776. (matn3[0][0]== 79 && matn3[1][1]== 79 && matn3[2][2]== 79 && matn3[3][3]== 79 )|| // diagonal
  777. (matn3[3][0]== 79 && matn3[2][1]== 79 && matn3[1][2]== 79 && matn3[0][3]== 79 )) // diagonal
  778. {
  779. system("cls");
  780. printf("\t\t\t\t*********************************** \n");
  781. printf("\t\t\t\t* Parabens player 2 voce venceu!!!*\n");
  782. printf("\t\t\t\t***********************************\n\n");
  783. velha.pont2++;
  784. return continua();
  785. }
  786. if(cont1==68){
  787. printf("\n\nEMPATE\n\n");
  788. return continua();}
  789. break; // break do caso 3
  790. case 4 :
  791. do
  792. {
  793. printf("Em qual linha e coluna vc deseja marcar.\n");
  794. printf("Linha: "); // Preencher o tabuleiro
  795. scanf("%d",&i); // Preencher o tabuleiro
  796. printf("Coluna: "); // Preencher o tabuleiro
  797. scanf("%d",&j); // Preencher o tabuleiro
  798. system("cls");
  799. }
  800. while((matn4[i-1][j-1]==88) || (matn4[i-1][j-1]==79)|| (i<1 || i>4) || (j<1 || j>4));// saber se tem x ou o marcado, se tiver, ele pede para digitar novamente
  801. matn4[i-1][j-1]= q ;
  802.  
  803. if((matn4[0][0]== 88 && matn4[0][1]== 88 && matn4[0][2]== 88 && matn4[0][3]== 88 )|| // linha
  804. (matn4[1][0]== 88 && matn4[1][1]== 88 && matn4[1][2]== 88 && matn4[1][3]== 88 )|| // linha
  805. (matn4[2][0]== 88 && matn4[2][1]== 88 && matn4[2][2]== 88 && matn4[2][3]== 88 )|| // linha
  806. (matn4[3][0]== 88 && matn4[3][1]== 88 && matn4[3][2]== 88 && matn4[3][3]== 88 )|| // linha
  807. (matn4[0][0]== 88 && matn4[1][0]== 88 && matn4[2][0]== 88 && matn4[3][0]== 88 )|| // coluna
  808. (matn4[0][1]== 88 && matn4[1][1]== 88 && matn4[2][1]== 88 && matn4[3][1]== 88 )|| // coluna
  809. (matn4[0][2]== 88 && matn4[1][2]== 88 && matn4[2][2]== 88 && matn4[3][2]== 88 )|| // coluna
  810. (matn4[0][3]== 88 && matn4[1][3]== 88 && matn4[2][3]== 88 && matn4[3][3]== 88 )|| // coluna
  811. (matn4[0][0]== 88 && matn4[1][1]== 88 && matn4[2][2]== 88 && matn4[3][3]== 88 )|| // diagonal
  812. (matn4[3][0]== 88 && matn4[2][1]== 88 && matn4[1][2]== 88 && matn4[0][3]== 88 )) // diagonal
  813. {
  814. system("cls");
  815. printf("*********************************** \n");
  816. printf("* Parabens player 1 voce venceu!!!*\n");
  817. printf("***********************************\n\n");
  818. velha.pont1++;
  819. return continua();
  820. }
  821.  
  822. if ((matn4[0][0]== 79 && matn4[0][1]== 79 && matn4[0][2]== 79 && matn4[0][3]== 79 )|| // linha
  823. (matn4[1][0]== 79 && matn4[1][1]== 79 && matn4[1][2]== 79 && matn4[1][3]== 79 )|| // linha
  824. (matn4[2][0]== 79 && matn4[2][1]== 79 && matn4[2][2]== 79 && matn4[2][3]== 79 )|| // linha
  825. (matn4[3][0]== 79 && matn4[3][1]== 79 && matn4[3][2]== 79 && matn4[3][3]== 79 )|| // linha
  826. (matn4[0][0]== 79 && matn4[1][0]== 79 && matn4[2][0]== 79 && matn4[3][0]== 79 )|| // coluna
  827. (matn4[0][1]== 79 && matn4[1][1]== 79 && matn4[2][1]== 79 && matn4[3][1]== 79 )|| // coluna
  828. (matn4[0][2]== 79 && matn4[1][2]== 79 && matn4[2][2]== 79 && matn4[3][2]== 79 )|| // coluna
  829. (matn4[0][3]== 79 && matn4[1][3]== 79 && matn4[2][3]== 79 && matn4[3][3]== 79 )|| // coluna
  830. (matn4[0][0]== 79 && matn4[1][1]== 79 && matn4[2][2]== 79 && matn4[3][3]== 79 )|| // diagonal
  831. (matn4[3][0]== 79 && matn4[2][1]== 79 && matn4[1][2]== 79 && matn4[0][3]== 79 )) // diagonal
  832. {
  833. system("cls");
  834. printf("*********************************** \n");
  835. printf("* Parabens player 1 voce venceu!!!*\n");
  836. printf("***********************************\n\n");
  837. velha.pont2++;
  838. return continua();
  839. }
  840.  
  841.  
  842. if(cont1==68){
  843. printf("\n\nEMPATE\n\n");
  844. return continua();}
  845. break;// break do caso 5
  846.  
  847. } //chave do switch
  848.  
  849. if((matn4[3][0]== 88 && matn3[3][0]== 88 && matn4[3][0]== 88 && matn1[3][0]== 88 )|| //colunaface // Teste para saber se ganhou
  850. (matn4[3][1]== 88 && matn3[3][1]== 88 && matn1[3][1]== 88 && matn1[3][1]== 88 )|| //colunaface
  851. (matn4[3][2]== 88 && matn3[3][2]== 88 && matn2[3][2]== 88 && matn1[3][2]== 88 )|| //colunaface
  852. (matn4[3][3]== 88 && matn3[3][3]== 88 && matn2[3][3]== 88 && matn1[3][3]== 88 )|| //colunaface
  853. (matn4[2][0]== 88 && matn3[2][0]== 88 && matn2[2][0]== 88 && matn1[2][0]== 88 )|| //colunaface
  854. (matn4[2][1]== 88 && matn3[2][1]== 88 && matn2[2][1]== 88 && matn1[2][1]== 88 )|| //colunaface
  855. (matn4[2][2]== 88 && matn3[2][2]== 88 && matn2[2][2]== 88 && matn1[2][2]== 88 )|| //colunaface
  856. (matn4[2][3]== 88 && matn3[2][3]== 88 && matn2[2][3]== 88 && matn1[2][3]== 88 )|| //colunaface
  857. (matn4[1][0]== 88 && matn3[1][0]== 88 && matn2[1][0]== 88 && matn1[1][0]== 88 )|| //colunaface
  858. (matn4[1][1]== 88 && matn3[1][1]== 88 && matn2[1][1]== 88 && matn1[1][1]== 88 )|| //colunaface
  859. (matn4[1][2]== 88 && matn3[1][2]== 88 && matn2[1][2]== 88 && matn1[1][2]== 88 )|| //colunaface
  860. (matn4[1][3]== 88 && matn3[1][3]== 88 && matn2[1][3]== 88 && matn1[1][3]== 88 )|| //colunaface
  861. (matn4[0][0]== 88 && matn3[0][0]== 88 && matn2[0][0]== 88 && matn1[0][0]== 88 )|| //colunaface
  862. (matn4[0][1]== 88 && matn3[0][1]== 88 && matn2[0][1]== 88 && matn1[0][1]== 88 )|| //colunaface
  863. (matn4[0][2]== 88 && matn3[0][2]== 88 && matn2[0][2]== 88 && matn1[0][2]== 88 )|| //colunaface
  864. (matn4[0][3]== 88 && matn3[0][3]== 88 && matn2[0][3]== 88 && matn1[0][3]== 88 )|| //colunaface
  865. (matn4[0][2]== 88 && matn3[0][2]== 88 && matn2[0][2]== 88 && matn1[0][2]== 88 )|| //colunaface
  866. (matn4[3][0]== 88 && matn3[3][1]== 88 && matn2[3][2]== 88 && matn1[3][3]== 88 )|| // \ diagonalface1
  867. (matn4[3][3]== 88 && matn3[3][2]== 88 && matn2[3][1]== 88 && matn1[3][0]== 88 )|| // / giagonalface1
  868. (matn4[2][0]== 88 && matn3[2][1]== 88 && matn2[2][2]== 88 && matn1[2][3]== 88 )|| // \ diagonalface2
  869. (matn4[2][3]== 88 && matn3[2][2]== 88 && matn2[2][1]== 88 && matn1[2][0]== 88 )|| // / giagonalface2
  870. (matn4[1][0]== 88 && matn3[1][1]== 88 && matn2[1][2]== 88 && matn1[1][3]== 88 )|| // \ diagonalface3
  871. (matn4[1][3]== 88 && matn3[1][2]== 88 && matn2[1][1]== 88 && matn1[1][0]== 88 )|| // \ diagonalface3
  872. (matn4[0][0]== 88 && matn3[0][1]== 88 && matn2[0][2]== 88 && matn1[0][3]== 88 )|| // \ diagonalface4
  873. (matn4[0][3]== 88 && matn3[0][2]== 88 && matn2[0][1]== 88 && matn1[0][0]== 88 )|| // \ diagonalface4
  874. (matn4[3][0]== 88 && matn3[2][1]== 88 && matn2[1][2]== 88 && matn1[0][3]== 88 )|| //diagonalcubo
  875. (matn4[3][3]== 88 && matn3[2][2]== 88 && matn2[1][1]== 88 && matn1[0][0]== 88 )|| //diagonalcubo
  876. (matn4[0][0]== 88 && matn3[1][1]== 88 && matn2[2][2]== 88 && matn1[3][3]== 88 )|| //diagonalcubo
  877. (matn4[0][3]== 88 && matn3[1][2]== 88 && matn2[2][1]== 88 && matn1[3][0]== 88 )) //diagonalcubo
  878. {
  879. system("cls");
  880. printf("*********************************** \n");
  881. printf("* Parabens player 1 voce venceu!!!*\n");
  882. printf("***********************************\n\n");
  883. velha.pont1++;
  884. return continua();
  885. }
  886.  
  887.  
  888. if((matn4[3][0]== 79 && matn3[3][0]== 79 && matn4[3][0]== 79 && matn1[3][0]== 79 )|| //colunaface // Teste para saber se ganhou
  889. (matn4[3][1]== 79 && matn3[3][1]== 79 && matn1[3][1]== 79 && matn1[3][1]== 79 )|| //colunaface
  890. (matn4[3][2]== 79 && matn3[3][2]== 79 && matn2[3][2]== 79 && matn1[3][2]== 79 )|| //colunaface
  891. (matn4[3][3]== 79 && matn3[3][3]== 79 && matn2[3][3]== 79 && matn1[3][3]== 79 )|| //colunaface
  892. (matn4[2][0]== 79 && matn3[2][0]== 79 && matn2[2][0]== 79 && matn1[2][0]== 79 )|| //colunaface
  893. (matn4[2][1]== 79 && matn3[2][1]== 79 && matn2[2][1]== 79 && matn1[2][1]== 79 )|| //colunaface
  894. (matn4[2][2]== 79 && matn3[2][2]== 79 && matn2[2][2]== 79 && matn1[2][2]== 79 )|| //colunaface
  895. (matn4[2][3]== 79 && matn3[2][3]== 79 && matn2[2][3]== 79 && matn1[2][3]== 79 )|| //colunaface
  896. (matn4[1][0]== 79 && matn3[1][0]== 79 && matn2[1][0]== 79 && matn1[1][0]== 79 )|| //colunaface
  897. (matn4[1][1]== 79 && matn3[1][1]== 79 && matn2[1][1]== 79 && matn1[1][1]== 79 )|| //colunaface
  898. (matn4[1][2]== 79 && matn3[1][2]== 79 && matn2[1][2]== 79 && matn1[1][2]== 79 )|| //colunaface
  899. (matn4[1][3]== 79 && matn3[1][3]== 79 && matn2[1][3]== 79 && matn1[1][3]== 79 )|| //colunaface
  900. (matn4[0][0]== 79 && matn3[0][0]== 79 && matn2[0][0]== 79 && matn1[0][0]== 79 )|| //colunaface
  901. (matn4[0][1]== 79 && matn3[0][1]== 79 && matn2[0][1]== 79 && matn1[0][1]== 79 )|| //colunaface
  902. (matn4[0][2]== 79 && matn3[0][2]== 79 && matn2[0][2]== 79 && matn1[0][2]== 79 )|| //colunaface
  903. (matn4[0][3]== 79 && matn3[0][3]== 79 && matn2[0][3]== 79 && matn1[0][3]== 79 )|| //colunaface
  904. (matn4[0][2]== 79 && matn3[0][2]== 79 && matn2[0][2]== 79 && matn1[0][2]== 79 )|| //colunaface
  905. (matn4[3][0]== 79 && matn3[3][1]== 79 && matn2[3][2]== 79 && matn1[3][3]== 79 )|| // \ diagonalface1
  906. (matn4[3][3]== 79 && matn3[3][2]== 79 && matn2[3][1]== 79 && matn1[3][0]== 79 )|| // / giagonalface1
  907. (matn4[2][0]== 79 && matn3[2][1]== 79 && matn2[2][2]== 79 && matn1[2][3]== 79 )|| // \ diagonalface2
  908. (matn4[2][3]== 79 && matn3[2][2]== 79 && matn2[2][1]== 79 && matn1[2][0]== 79 )|| // / giagonalface2
  909. (matn4[1][0]== 79 && matn3[1][1]== 79 && matn2[1][2]== 79 && matn1[1][3]== 79 )|| // \ diagonalface3
  910. (matn4[1][3]== 79 && matn3[1][2]== 79 && matn2[1][1]== 79 && matn1[1][0]== 79 )|| // \ diagonalface3
  911. (matn4[0][0]== 79 && matn3[0][1]== 79 && matn2[0][2]== 79 && matn1[0][3]== 79 )|| // \ diagonalface4
  912. (matn4[0][3]== 79 && matn3[0][2]== 79 && matn2[0][1]== 79 && matn1[0][0]== 79 )|| // \ diagonalface4
  913. (matn4[3][0]== 79 && matn3[2][1]== 79 && matn2[1][2]== 79 && matn1[0][3]== 79 )|| //diagonalcubo
  914. (matn4[3][3]== 79 && matn3[2][2]== 79 && matn2[1][1]== 79 && matn1[0][0]== 79 )|| //diagonalcubo
  915. (matn4[0][0]== 79 && matn3[1][1]== 79 && matn2[2][2]== 79 && matn1[3][3]== 79 )|| //diagonalcubo
  916. (matn4[0][3]== 79 && matn3[1][2]== 79 && matn2[2][1]== 79 && matn1[3][0]== 79 )) //diagonalcubo
  917. {
  918. system("cls");
  919. printf("*********************************** \n");
  920. printf("* Parabens player 2 voce venceu!!!*\n");
  921. printf("***********************************\n\n");
  922. velha.pont2++;
  923. return continua();
  924. }
  925.  
  926. if(cont1==68){
  927. printf("\n\nEMPATE\n\n");
  928. return continua();}
  929. andarn4();
  930. andarn3();
  931. andarn2();
  932. andarn1();
  933. cont1++; // contador para o primeiro if else
  934. }
  935. while (cont1<68);
  936.  
  937. if(velha.pont1 > velha.pont2)
  938. printf("Jogador 1 venceu!\n\n");
  939. else
  940. printf("Jogador 2 venceu!\n\n");
  941.  
  942. return continua();
  943. }
  944. void jogo1 (){
  945.  
  946. char matn1[4][4];
  947. char matn2[4][4];
  948. char matn3[4][4];
  949. char matn4[4][4];
  950. int q;
  951. int i=0,j=0,k=0,m=0,aux1,cont1=4,aux2,contx=0,conty=0;
  952. int andarn4(){
  953. printf(" 4 andar\n");
  954. printf("\n %c| %c| %c| %c\n",matn4[0][0],matn4[0][1],matn4[0][2], matn4[0][3]); //Printar o tabuleiro
  955. printf("___________\n"); //Printar o tabuleiro
  956. printf(" %c| %c| %c| %c\n",matn4[1][0],matn4[1][1],matn4[1][2], matn4[1][3]); //Printar o tabuleiro
  957. printf("___________\n"); //Printar o tabuleiro
  958. printf(" %c| %c| %c| %c\n",matn4[2][0],matn4[2][1],matn4[2][2], matn4[2][3]); //Printar o tabuleiro
  959. printf("___________\n"); //Printar o tabuleiro
  960. printf(" %c| %c| %c| %c\n",matn4[3][0],matn4[3][1],matn4[3][2], matn4[3][3]); //Printar o tabuleiro
  961. printf(" \n");
  962. }
  963. int andarn3(){
  964. printf(" 3 andar\n");
  965. printf("\n %c| %c| %c| %c\n",matn3[0][0],matn3[0][1],matn3[0][2], matn3[0][3]); //Printar o tabuleiro
  966. printf("___________\n"); //Printar o tabuleiro
  967. printf(" %c| %c| %c| %c\n",matn3[1][0],matn3[1][1],matn3[1][2], matn3[1][3]); //Printar o tabuleiro
  968. printf("___________\n"); //Printar o tabuleiro
  969. printf(" %c| %c| %c| %c\n",matn3[2][0],matn3[2][1],matn3[2][2], matn3[2][3]); //Printar o tabuleiro
  970. printf("___________\n"); //Printar o tabuleiro
  971. printf(" %c| %c| %c| %c\n",matn3[3][0],matn3[3][1],matn3[3][2], matn3[3][3]); //Printar o tabuleiro
  972. printf(" \n");
  973. }
  974. int andarn2 (){
  975. printf(" 2 andar\n");
  976. printf("\n %c| %c| %c| %c\n",matn2[0][0],matn2[0][1],matn2[0][2], matn2[0][3]); //Printar o tabuleiro
  977. printf("___________\n"); //Printar o tabuleiro
  978. printf(" %c| %c| %c| %c\n",matn2[1][0],matn2[1][1],matn2[1][2], matn2[1][3]); //Printar o tabuleiro
  979. printf("___________\n"); //Printar o tabuleiro
  980. printf(" %c| %c| %c| %c\n",matn2[2][0],matn2[2][1],matn2[2][2], matn2[2][3]); //Printar o tabuleiro
  981. printf("___________\n"); //Printar o tabuleiro
  982. printf(" %c| %c| %c| %c\n",matn2[3][0],matn2[3][1],matn2[3][2], matn2[3][3]); //Printar o tabuleiro
  983. printf(" \n ");
  984. }
  985. int andarn1(){
  986. printf(" 1 andar\n");
  987. printf("\n %c| %c| %c| %c\n",matn1[0][0],matn1[0][1],matn1[0][2], matn1[0][3]); //Printar o tabuleiro
  988. printf("___________\n"); //Printar o tabuleiro
  989. printf(" %c| %c| %c| %c\n",matn1[1][0],matn1[1][1],matn1[1][2], matn1[1][3]); //Printar o tabuleiro
  990. printf("___________\n"); //Printar o tabuleiro
  991. printf(" %c| %c| %c| %c\n",matn1[2][0],matn1[2][1],matn1[2][2], matn1[2][3]); //Printar o tabuleiro
  992. printf("___________\n"); //Printar o tabuleiro
  993. printf(" %c| %c| %c| %c\n",matn1[3][0],matn1[3][1],matn1[3][2], matn1[3][3]); //Printar o tabuleiro
  994. printf(" \n \n \n ");
  995. printf(" \n\n");
  996. }
  997. for(i=0; i <=3; i++) // preenchimento da matriz com ' '
  998. {
  999. for(j=0; j <= 3 ; j++) //preenche todas a posição com ' ' //
  1000. {
  1001. matn1[i][j]=' ';
  1002. matn2[i][j]=' ';
  1003. matn3[i][j]=' ';
  1004. matn4[i][j]=' ';
  1005. } // SEGUNDO LACO FOR
  1006. } // PRIMEIRO LACO FOR
  1007. andarn4();
  1008. andarn3();
  1009. andarn2();
  1010. andarn1();
  1011. do
  1012. {
  1013. if (cont1 % 3 == 1) // SE FOR 0, q=88; SERÁ O JOGADOR 1, SE FOR q=79;, JOGADOR 2
  1014. q=88;
  1015. if (cont1 % 3 == 2) // SE FOR 0, q=88; SERÁ O JOGADOR 1, SE FOR q=79;, JOGADOR 2
  1016. q=79;
  1017. if (cont1 % 3 == 0) // SE FOR 0, q=88; SERÁ O JOGADOR 1, SE FOR q=79;, JOGADOR 2
  1018. q=30;
  1019. do
  1020. {
  1021. printf("Escolha o andar: 1, 2, 3 ou 4:\n");
  1022. scanf("%d", &aux1);
  1023. if(aux1==1){ //Escolher o Andar
  1024. if ((matn1[0][0]==88 || matn1[0][0]==79 || matn1[0][0]==30) && (matn1[0][1]==88 || matn1[0][1]==79 || matn1[0][1]==30) && //Verificar se o andar está preenchido
  1025. (matn1[0][2]==88 || matn1[0][2]==79 || matn1[0][2]==30) && (matn1[0][3]==88 || matn1[0][3]==79 || matn1[0][3]==30) && //Verificar se o andar está preenchido
  1026. (matn1[1][0]==88 || matn1[1][0]==79 || matn1[1][0]==30) && (matn1[1][1]==88 || matn1[1][1]==79 || matn1[1][1]==30) && //Verificar se o andar está preenchido
  1027. (matn1[1][2]==88 || matn1[1][2]==79 || matn1[1][2]==30) && (matn1[1][3]==88 || matn1[1][3]==79 || matn1[1][3]==30) && //Verificar se o andar está preenchido
  1028. (matn1[2][0]==88 || matn1[2][0]==79 || matn1[2][0]==30) && (matn1[2][1]==88 || matn1[2][1]==79 || matn1[2][1]==30) && //Verificar se o andar está preenchido
  1029. (matn1[2][2]==88 || matn1[2][2]==79 || matn1[2][2]==30) && (matn1[2][3]==88 || matn1[2][3]==79 || matn1[2][3]==30) && //Verificar se o andar está preenchido
  1030. (matn1[3][0]==88 || matn1[3][0]==79 || matn1[3][0]==30) && (matn1[3][1]==88 || matn1[3][1]==79 || matn1[3][1]==30) && //Verificar se o andar está preenchido
  1031. (matn1[3][2]==88 || matn1[3][2]==79 || matn1[3][2]==30) && (matn1[3][3]==88 || matn1[3][3]==79 || matn1[3][3]==30)) //Verificar se o andar está preenchido
  1032. {
  1033. do{
  1034. printf("ANDAR 1 PREENCHIDO!\nEscolha o andar disponivel: '2','3' ou '4':\n");
  1035. scanf("%d", &aux1);} while((aux1 != 2) && (aux1 != 3) && (aux1 != 4));
  1036. }
  1037. }
  1038. if(aux1==2){
  1039. if ((matn2[0][0]==88 || matn2[0][0]==79 || matn2[0][0]==30) && (matn2[0][1]==88 || matn2[0][1]==79 || matn2[0][1]==30) && //Verificar se o andar está preenchido
  1040. (matn2[0][2]==88 || matn2[0][2]==79 || matn2[0][2]==30) && (matn2[0][3]==88 || matn2[0][3]==79 || matn2[0][3]==30) &&
  1041. (matn2[1][0]==88 || matn2[1][0]==79 || matn2[1][0]==30) && (matn2[1][1]==88 || matn2[1][1]==79 || matn2[1][1]==30) &&
  1042. (matn2[1][2]==88 || matn2[1][2]==79 || matn2[1][2]==30) && (matn2[1][3]==88 || matn2[1][3]==79 || matn2[1][3]==30) &&
  1043. (matn2[2][0]==88 || matn2[2][0]==79 || matn2[2][0]==30) && (matn2[2][1]==88 || matn2[2][1]==79 || matn2[2][1]==30) &&
  1044. (matn2[2][2]==88 || matn2[2][2]==79 || matn2[2][2]==30) && (matn2[2][3]==88 || matn2[2][3]==79 || matn2[2][3]==30) &&
  1045. (matn2[3][0]==88 || matn2[3][0]==79 || matn2[3][0]==30) && (matn2[3][1]==88 || matn2[3][1]==79 || matn2[3][1]==30) &&
  1046. (matn2[3][2]==88 || matn2[3][2]==79 || matn2[3][2]==30) && (matn2[3][3]==88 || matn2[3][3]==79 || matn2[3][3]==30))
  1047. {
  1048. do{
  1049. printf("ANDAR 2 PREENCHIDO!\nEscolha o andar disponivel: '1','3' ou '4':\n");
  1050. scanf("%d", &aux1);} while((aux1 != 1) && (aux1 != 3) && (aux1 != 4));
  1051. }
  1052. }
  1053. if(aux1==3){
  1054. if ((matn3[0][0]==88 || matn3[0][0]==79 || matn3[0][0]==30) && (matn3[0][1]==88 || matn3[0][1]==79 || matn3[0][1]==30) && //Verificar se o andar está preenchido
  1055. (matn3[0][2]==88 || matn3[0][2]==79 || matn3[0][2]==30) && (matn3[0][3]==88 || matn3[0][3]==79 || matn3[0][3]==30) &&
  1056. (matn3[1][0]==88 || matn3[1][0]==79 || matn3[1][0]==30) && (matn3[1][1]==88 || matn3[1][1]==79 || matn3[1][1]==30) &&
  1057. (matn3[1][2]==88 || matn3[1][2]==79 || matn3[1][2]==30) && (matn3[1][3]==88 || matn3[1][3]==79 || matn3[1][3]==30) &&
  1058. (matn3[2][0]==88 || matn3[2][0]==79 || matn3[2][0]==30) && (matn3[2][1]==88 || matn3[2][1]==79 || matn3[2][1]==30) &&
  1059. (matn3[2][2]==88 || matn3[2][2]==79 || matn3[2][2]==30) && (matn3[2][3]==88 || matn3[2][3]==79 || matn3[2][3]==30) &&
  1060. (matn3[3][0]==88 || matn3[3][0]==79 || matn3[3][0]==30) && (matn3[3][1]==88 || matn3[3][1]==79 || matn3[3][1]==30) &&
  1061. (matn3[3][2]==88 || matn3[3][2]==79 || matn3[3][2]==30) && (matn3[3][3]==88 || matn3[3][3]==79 || matn3[3][3]==30))
  1062. {
  1063. do{
  1064. printf("ANDAR 3 PREENCHIDO!\nEscolha o andar disponivel: '1','2' ou '4':\n");
  1065. scanf("%d", &aux1);} while((aux1 != 1) && (aux1 != 2) && (aux1 != 4));
  1066. }
  1067. }
  1068. if(aux1==4){
  1069. if ((matn4[0][0]==88 || matn4[0][0]==79 || matn4[0][0]==30) && (matn4[0][1]==88 || matn4[0][1]==79 || matn4[0][1]==30) && //Verificar se o andar está preenchido
  1070. (matn4[0][2]==88 || matn4[0][2]==79 || matn4[0][2]==30) && (matn4[0][3]==88 || matn4[0][3]==79 || matn4[0][3]==30) &&
  1071. (matn4[1][0]==88 || matn4[1][0]==79 || matn4[1][0]==30) && (matn4[1][1]==88 || matn4[1][1]==79 || matn4[1][1]==30) &&
  1072. (matn4[1][2]==88 || matn4[1][2]==79 || matn4[1][2]==30) && (matn4[1][3]==88 || matn4[1][3]==79 || matn4[1][3]==30) &&
  1073. (matn4[2][0]==88 || matn4[2][0]==79 || matn4[2][0]==30) && (matn4[2][1]==88 || matn4[2][1]==79 || matn4[2][1]==30) &&
  1074. (matn4[2][2]==88 || matn4[2][2]==79 || matn4[2][2]==30) && (matn4[2][3]==88 || matn4[2][3]==79 || matn4[2][3]==30) &&
  1075. (matn4[3][0]==88 || matn4[3][0]==79 || matn4[3][0]==30) && (matn4[3][1]==88 || matn4[3][1]==79 || matn4[3][1]==30) &&
  1076. (matn4[3][2]==88 || matn4[3][2]==79 || matn4[3][2]==30) && (matn4[3][3]==88 || matn4[3][3]==79 || matn4[3][3]==30))
  1077. {
  1078. do{
  1079. printf("ANDAR 4 PREENCHIDO!\nEscolha o andar disponivel: '1','2' ou '3':\n");
  1080. scanf("%d", &aux1);} while((aux1 != 1) && (aux1 != 2) && (aux1 != 3));
  1081. }
  1082. }
  1083. } while((aux1 != 1) && (aux1 != 2) && (aux1 != 3) && (aux1 != 4)); //Enquanto o usuario não digitar os andares 1,2,3 e 4, ele continua pedindo
  1084. switch(aux1) // jogo
  1085. {
  1086. case 1 :
  1087. do
  1088. {
  1089. printf("Em qual linha e coluna vc deseja marcar.\n");
  1090. printf("Linha: "); // Preencher o tabuleiro
  1091. scanf("%d",&i); // Preencher o tabuleiro
  1092. printf("Coluna: "); // Preencher o tabuleiro
  1093. scanf("%d",&j); // Preencher o tabuleiro
  1094. system("cls");
  1095. }
  1096. while((matn1[i-1][j-1]==88) || (matn1[i-1][j-1]==79)|| (i<1 || i>4) || (j<1 || j>4));// saber se tem x ou o marcado, se tiver, ele pede para digitar novamente
  1097. matn1[i-1][j-1]= q ;
  1098. // condicoes matriz n1
  1099. if((matn1[0][0]== 88 && matn1[0][1]== 88 && matn1[0][2]== 88 && matn1[0][3]== 88 )|| // linha // Verificar se ganhou
  1100. (matn1[1][0]== 88 && matn1[1][1]== 88 && matn1[1][2]== 88 && matn1[1][3]== 88 )|| // linha
  1101. (matn1[2][0]== 88 && matn1[2][1]== 88 && matn1[2][2]== 88 && matn1[2][3]== 88 )|| // linha
  1102. (matn1[3][0]== 88 && matn1[3][1]== 88 && matn1[3][2]== 88 && matn1[3][3]== 88 )|| // linha
  1103. (matn1[0][0]== 88 && matn1[1][0]== 88 && matn1[2][0]== 88 && matn1[3][0]== 88 )|| // coluna
  1104. (matn1[0][1]== 88 && matn1[1][1]== 88 && matn1[2][1]== 88 && matn1[3][1]== 88 )|| // coluna
  1105. (matn1[0][2]== 88 && matn1[1][2]== 88 && matn1[2][2]== 88 && matn1[3][2]== 88 )|| // coluna
  1106. (matn1[0][3]== 88 && matn1[1][3]== 88 && matn1[2][3]== 88 && matn1[3][3]== 88 )|| // coluna
  1107. (matn1[0][0]== 88 && matn1[1][1]== 88 && matn1[2][2]== 88 && matn1[3][3]== 88 )|| // diagonal
  1108. (matn1[3][0]== 88 && matn1[2][1]== 88 && matn1[1][2]== 88 && matn1[0][3]== 88 )) // diagonal
  1109. {
  1110. printf("\t\t\t\t*********************************** \n");
  1111. printf("\t\t\t\t* Parabens player 1 voce venceu!!!*\n");
  1112. printf("\t\t\t\t***********************************\n\n");
  1113. velha.pont1++;
  1114. system("pause");
  1115. return continua();
  1116. }
  1117. if((matn1[0][0]== 79 && matn1[0][1]== 79 && matn1[0][2]== 79 && matn1[0][3]== 79 )|| // linha // Verificar se ganhou
  1118. (matn1[1][0]== 79 && matn1[1][1]== 79 && matn1[1][2]== 79 && matn1[1][3]== 79 )|| // linha
  1119. (matn1[2][0]== 79 && matn1[2][1]== 79 && matn1[2][2]== 79 && matn1[2][3]== 79 )|| // linha
  1120. (matn1[3][0]== 79 && matn1[3][1]== 79 && matn1[3][2]== 79 && matn1[3][3]== 79 )|| // linha
  1121. (matn1[0][0]== 79 && matn1[1][0]== 79 && matn1[2][0]== 79 && matn1[3][0]== 79 )|| // coluna
  1122. (matn1[0][1]== 79 && matn1[1][1]== 79 && matn1[2][1]== 79 && matn1[3][1]== 79 )|| // coluna
  1123. (matn1[0][2]== 79 && matn1[1][2]== 79 && matn1[2][2]== 79 && matn1[3][2]== 79 )|| // coluna
  1124. (matn1[0][3]== 79 && matn1[1][3]== 79 && matn1[2][3]== 79 && matn1[3][3]== 79 )|| // coluna
  1125. (matn1[0][0]== 79 && matn1[1][1]== 79 && matn1[2][2]== 79 && matn1[3][3]== 79 )|| // diagonal
  1126. (matn1[3][0]== 79 && matn1[2][1]== 79 && matn1[1][2]== 79 && matn1[0][3]== 79 )) // diagonal
  1127. {
  1128. printf("\t\t\t\t*********************************** \n");
  1129. printf("\t\t\t\t* Parabens player 2 voce venceu!!!*\n");
  1130. printf("\t\t\t\t***********************************\n\n");
  1131. velha.pont2++;
  1132. system("pause");
  1133. return continua();
  1134. }
  1135.  
  1136. if((matn1[0][0]== 30 && matn1[0][1]== 30 && matn1[0][2]== 30 && matn1[0][3]== 30 )|| // linha // Verificar se ganhou
  1137. (matn1[1][0]== 30 && matn1[1][1]== 30 && matn1[1][2]== 30 && matn1[1][3]== 30 )|| // linha
  1138. (matn1[2][0]== 30 && matn1[2][1]== 30 && matn1[2][2]== 30 && matn1[2][3]== 30 )|| // linha
  1139. (matn1[3][0]== 30 && matn1[3][1]== 30 && matn1[3][2]== 30 && matn1[3][3]== 30 )|| // linha
  1140. (matn1[0][0]== 30 && matn1[1][0]== 30 && matn1[2][0]== 30 && matn1[3][0]== 30 )|| // coluna
  1141. (matn1[0][1]== 30 && matn1[1][1]== 30 && matn1[2][1]== 30 && matn1[3][1]== 30 )|| // coluna
  1142. (matn1[0][2]== 30 && matn1[1][2]== 30 && matn1[2][2]== 30 && matn1[3][2]== 30 )|| // coluna
  1143. (matn1[0][3]== 30 && matn1[1][3]== 30 && matn1[2][3]== 30 && matn1[3][3]== 30 )|| // coluna
  1144. (matn1[0][0]== 30 && matn1[1][1]== 30 && matn1[2][2]== 30 && matn1[3][3]== 30 )|| // diagonal
  1145. (matn1[3][0]== 30 && matn1[2][1]== 30 && matn1[1][2]== 30 && matn1[0][3]== 30 )) // diagonal
  1146. {
  1147. printf("\t\t\t\t*********************************** \n");
  1148. printf("\t\t\t\t* Parabens player 3 voce venceu!!!*\n");
  1149. printf("\t\t\t\t***********************************\n\n");
  1150. velha.pont3++;
  1151. system("pause");
  1152. return continua();
  1153. }
  1154. if(cont1==68){
  1155. printf("\n\nEMPATE\n\n");
  1156. system("pause");
  1157. return continua();}
  1158. break; // break do caso 1
  1159. case 2 :
  1160. do
  1161. {
  1162. printf("Em qual linha e coluna vc deseja marcar:\n");
  1163. printf("Linha: "); // Preencher o tabuleiro
  1164. scanf("%d",&i); // Preencher o tabuleiro
  1165. printf("Coluna: "); // Preencher o tabuleiro
  1166. scanf("%d",&j); // Preencher o tabuleiro
  1167. system("cls");
  1168. }
  1169. while((matn2[i-1][j-1]==88) || (matn2[i-1][j-1]==79)|| (i<1 || i>4) || (j<1 || j>4));// saber se tem x ou o marcado, se tiver, ele pede para digitar novamente
  1170. matn2[i-1][j-1]= q ;
  1171. if((matn2[0][0]== 88 && matn2[0][1]== 88 && matn2[0][2]== 88 && matn2[0][3]== 88 )|| // linha // Verificar se ganhou
  1172. (matn2[1][0]== 88 && matn2[1][1]== 88 && matn2[1][2]== 88 && matn2[1][3]== 88 )|| // linha
  1173. (matn2[2][0]== 88 && matn2[2][1]== 88 && matn2[2][2]== 88 && matn2[2][3]== 88 )|| // linha
  1174. (matn2[3][0]== 88 && matn2[3][1]== 88 && matn2[3][2]== 88 && matn2[3][3]== 88 )|| // linha
  1175. (matn2[0][0]== 88 && matn2[1][0]== 88 && matn2[2][0]== 88 && matn2[3][0]== 88 )|| // coluna
  1176. (matn2[0][1]== 88 && matn2[1][1]== 88 && matn2[2][1]== 88 && matn2[3][1]== 88 )|| // coluna
  1177. (matn2[0][2]== 88 && matn2[1][2]== 88 && matn2[2][2]== 88 && matn2[3][2]== 88 )|| // coluna
  1178. (matn2[0][3]== 88 && matn2[1][3]== 88 && matn2[2][3]== 88 && matn2[3][3]== 88 )|| // coluna
  1179. (matn2[0][0]== 88 && matn2[1][1]== 88 && matn2[2][2]== 88 && matn2[3][3]== 88 )|| // diagonal
  1180. (matn2[3][0]== 88 && matn2[2][1]== 88 && matn2[1][2]== 88 && matn2[0][3]== 88 )) // diagonal
  1181. {
  1182. printf("\t\t\t\t*********************************** \n");
  1183. printf("\t\t\t\t* Parabens player 1 voce venceu!!!*\n");
  1184. printf("\t\t\t\t***********************************\n\n");
  1185. velha.pont1++;
  1186. system("pause");
  1187. return continua();
  1188. }
  1189. if((matn2[0][0]== 79 && matn2[0][1]== 79 && matn2[0][2]== 79 && matn2[0][3]== 79 )|| // linha // Verificar se ganhou
  1190. (matn2[1][0]== 79 && matn2[1][1]== 79 && matn2[1][2]== 79 && matn2[1][3]== 79 )|| // linha
  1191. (matn2[2][0]== 79 && matn2[2][1]== 79 && matn2[2][2]== 79 && matn2[2][3]== 79 )|| // linha
  1192. (matn2[3][0]== 79 && matn2[3][1]== 79 && matn2[3][2]== 79 && matn2[3][3]== 79 )|| // linha
  1193. (matn2[0][0]== 79 && matn2[1][0]== 79 && matn2[2][0]== 79 && matn2[3][0]== 79 )|| // coluna
  1194. (matn2[0][1]== 79 && matn2[1][1]== 79 && matn2[2][1]== 79 && matn2[3][1]== 79 )|| // coluna
  1195. (matn2[0][2]== 79 && matn2[1][2]== 79 && matn2[2][2]== 79 && matn2[3][2]== 79 )|| // coluna
  1196. (matn2[0][3]== 79 && matn2[1][3]== 79 && matn2[2][3]== 79 && matn2[3][3]== 79 )|| // coluna
  1197. (matn2[0][0]== 79 && matn2[1][1]== 79 && matn2[2][2]== 79 && matn2[3][3]== 79 )|| // diagonal
  1198. (matn2[3][0]== 79 && matn2[2][1]== 79 && matn2[1][2]== 79 && matn2[0][3]== 79 )) // diagonal
  1199. {
  1200. printf("\t\t\t\t*********************************** \n");
  1201. printf("\t\t\t\t* Parabens player 2 voce venceu!!!*\n");
  1202. printf("\t\t\t\t***********************************\n\n");
  1203. velha.pont2++;
  1204. system("pause");
  1205. return continua();
  1206. }
  1207. if((matn2[0][0]== 30 && matn2[0][1]== 30 && matn2[0][2]== 30 && matn2[0][3]== 30 )|| // linha // Verificar se ganhou
  1208. (matn2[1][0]== 30 && matn2[1][1]== 30 && matn2[1][2]== 30 && matn2[1][3]== 30 )|| // linha
  1209. (matn2[2][0]== 30 && matn2[2][1]== 30 && matn2[2][2]== 30 && matn2[2][3]== 30 )|| // linha
  1210. (matn2[3][0]== 30 && matn2[3][1]== 30 && matn2[3][2]== 30 && matn2[3][3]== 30 )|| // linha
  1211. (matn2[0][0]== 30 && matn2[1][0]== 30 && matn2[2][0]== 30 && matn2[3][0]== 30 )|| // coluna
  1212. (matn2[0][1]== 30 && matn2[1][1]== 30 && matn2[2][1]== 30 && matn2[3][1]== 30 )|| // coluna
  1213. (matn2[0][2]== 30 && matn2[1][2]== 30 && matn2[2][2]== 30 && matn2[3][2]== 30 )|| // coluna
  1214. (matn2[0][3]== 30 && matn2[1][3]== 30 && matn2[2][3]== 30 && matn2[3][3]== 30 )|| // coluna
  1215. (matn2[0][0]== 30 && matn2[1][1]== 30 && matn2[2][2]== 30 && matn2[3][3]== 30 )|| // diagonal
  1216. (matn2[3][0]== 30 && matn2[2][1]== 30 && matn2[1][2]== 30 && matn2[0][3]== 30 )) // diagonal
  1217. {
  1218. printf("\t\t\t\t*********************************** \n");
  1219. printf("\t\t\t\t* Parabens player 3 voce venceu!!!*\n");
  1220. printf("\t\t\t\t***********************************\n\n");
  1221. velha.pont3++;
  1222. system("pause");
  1223. return continua();
  1224. }
  1225. if(cont1==68){
  1226. printf("\n\nEMPATE\n\n");
  1227. system("pause");
  1228. return continua();}
  1229.  
  1230. break;// break do caso 2
  1231. case 3 :
  1232. do
  1233. {
  1234. printf("Em qual linha e coluna vc deseja marcar.\n");
  1235. printf("Linha: "); // Preencher o tabuleiro
  1236. scanf("%d",&i); // Preencher o tabuleiro
  1237. printf("Coluna: "); // Preencher o tabuleiro
  1238. scanf("%d",&j); // Preencher o tabuleiro
  1239. system("cls");
  1240. }
  1241. while((matn3[i-1][j-1]==88) || (matn3[i-1][j-1]==79)|| (i<1 || i>4) || (j<1 || j>4)); // saber se tem x ou o marcado, se tiver, ele pede para digitar novamente
  1242. matn3[i-1][j-1]= q ;
  1243. // condicoes matriz n3
  1244. if((matn3[0][0]== 88 && matn3[0][1]== 88 && matn3[0][2]== 88 && matn3[0][3]== 88 )|| // linha // Verificar se ganhou
  1245. (matn3[1][0]== 88 && matn3[1][1]== 88 && matn3[1][2]== 88 && matn3[1][3]== 88 )|| // linha
  1246. (matn3[2][0]== 88 && matn3[2][1]== 88 && matn3[2][2]== 88 && matn3[2][3]== 88 )|| // linha
  1247. (matn3[3][0]== 88 && matn3[3][1]== 88 && matn3[3][2]== 88 && matn3[3][3]== 88 )|| // linha
  1248. (matn3[0][0]== 88 && matn3[1][0]== 88 && matn3[2][0]== 88 && matn3[3][0]== 88 )|| // coluna
  1249. (matn3[0][1]== 88 && matn3[1][1]== 88 && matn3[2][1]== 88 && matn3[3][1]== 88 )|| // coluna
  1250. (matn3[0][2]== 88 && matn3[1][2]== 88 && matn3[2][2]== 88 && matn3[3][2]== 88 )|| // coluna
  1251. (matn3[0][3]== 88 && matn3[1][3]== 88 && matn3[2][3]== 88 && matn3[3][3]== 88 )|| // coluna
  1252. (matn3[0][0]== 88 && matn3[1][1]== 88 && matn3[2][2]== 88 && matn3[3][3]== 88 )|| // diagonal
  1253. (matn3[3][0]== 88 && matn3[2][1]== 88 && matn3[1][2]== 88 && matn3[0][3]== 88 )) // diagonal
  1254. {
  1255. printf("\t\t\t\t*********************************** \n");
  1256. printf("\t\t\t\t* Parabens player 1 voce venceu!!!*\n");
  1257. printf("\t\t\t\t***********************************\n\n");
  1258. velha.pont1++;
  1259. system("pause");
  1260. return continua();
  1261. }
  1262. if ((matn3[0][0]== 79 && matn3[0][1]== 79 && matn3[0][2]== 79 && matn3[0][3]== 79 )|| // linha
  1263. (matn3[1][0]== 79 && matn3[1][1]== 79 && matn3[1][2]== 79 && matn3[1][3]== 79 )|| // linha
  1264. (matn3[2][0]== 79 && matn3[2][1]== 79 && matn3[2][2]== 79 && matn3[2][3]== 79 )|| // linha
  1265. (matn3[3][0]== 79 && matn3[3][1]== 79 && matn3[3][2]== 79 && matn3[3][3]== 79 )|| // linha
  1266. (matn3[0][0]== 79 && matn3[1][0]== 79 && matn3[2][0]== 79 && matn3[3][0]== 79 )|| // coluna
  1267. (matn3[0][1]== 79 && matn3[1][1]== 79 && matn3[2][1]== 79 && matn3[3][1]== 79 )|| // coluna
  1268. (matn3[0][2]== 79 && matn3[1][2]== 79 && matn3[2][2]== 79 && matn3[3][2]== 79 )|| // coluna
  1269. (matn3[0][3]== 79 && matn3[1][3]== 79 && matn3[2][3]== 79 && matn3[3][3]== 79 )|| // coluna
  1270. (matn3[0][0]== 79 && matn3[1][1]== 79 && matn3[2][2]== 79 && matn3[3][3]== 79 )|| // diagonal
  1271. (matn3[3][0]== 79 && matn3[2][1]== 79 && matn3[1][2]== 79 && matn3[0][3]== 79 )) // diagonal
  1272. {
  1273. printf("\t\t\t\t*********************************** \n");
  1274. printf("\t\t\t\t* Parabens player 2 voce venceu!!!*\n");
  1275. printf("\t\t\t\t***********************************\n\n");
  1276. velha.pont2++;
  1277. system("pause");
  1278. return continua();
  1279. }
  1280. if ((matn3[0][0]== 30 && matn3[0][1]== 30 && matn3[0][2]== 30 && matn3[0][3]== 30 )|| // linha
  1281. (matn3[1][0]== 30 && matn3[1][1]== 30 && matn3[1][2]== 30 && matn3[1][3]== 30 )|| // linha
  1282. (matn3[2][0]== 30 && matn3[2][1]== 30 && matn3[2][2]== 30 && matn3[2][3]== 30 )|| // linha
  1283. (matn3[3][0]== 30 && matn3[3][1]== 30 && matn3[3][2]== 30 && matn3[3][3]== 30 )|| // linha
  1284. (matn3[0][0]== 30 && matn3[1][0]== 30 && matn3[2][0]== 30 && matn3[3][0]== 30 )|| // coluna
  1285. (matn3[0][1]== 30 && matn3[1][1]== 30 && matn3[2][1]== 30 && matn3[3][1]== 30 )|| // coluna
  1286. (matn3[0][2]== 30 && matn3[1][2]== 30 && matn3[2][2]== 30 && matn3[3][2]== 30 )|| // coluna
  1287. (matn3[0][3]== 30 && matn3[1][3]== 30 && matn3[2][3]== 30 && matn3[3][3]== 30 )|| // coluna
  1288. (matn3[0][0]== 30 && matn3[1][1]== 30 && matn3[2][2]== 30 && matn3[3][3]== 30 )|| // diagonal
  1289. (matn3[3][0]== 30 && matn3[2][1]== 30 && matn3[1][2]== 30 && matn3[0][3]== 30 )) // diagonal
  1290. {
  1291. printf("\t\t\t\t*********************************** \n");
  1292. printf("\t\t\t\t* Parabens player 3 voce venceu!!!*\n");
  1293. printf("\t\t\t\t***********************************\n\n");
  1294. velha.pont3++;
  1295. system("pause");
  1296. return continua();
  1297. }
  1298. if(cont1==68){
  1299. printf("\n\nEMPATE\n\n");
  1300. system("pause");
  1301. return continua();}
  1302. break; // break do caso 3
  1303. case 4 :
  1304. do
  1305. {
  1306. printf("Em qual linha e coluna vc deseja marcar.\n");
  1307. printf("Linha: "); // Preencher o tabuleiro
  1308. scanf("%d",&i); // Preencher o tabuleiro
  1309. printf("Coluna: "); // Preencher o tabuleiro
  1310. scanf("%d",&j); // Preencher o tabuleiro
  1311. system("cls");
  1312. }
  1313. while((matn4[i-1][j-1]==88) || (matn4[i-1][j-1]==79)|| (i<1 || i>4) || (j<1 || j>4));// saber se tem x ou o marcado, se tiver, ele pede para digitar novamente
  1314. matn4[i-1][j-1]= q ;
  1315. if((matn4[0][0]== 88 && matn4[0][1]== 88 && matn4[0][2]== 88 && matn4[0][3]== 88 )|| // linha
  1316. (matn4[1][0]== 88 && matn4[1][1]== 88 && matn4[1][2]== 88 && matn4[1][3]== 88 )|| // linha
  1317. (matn4[2][0]== 88 && matn4[2][1]== 88 && matn4[2][2]== 88 && matn4[2][3]== 88 )|| // linha
  1318. (matn4[3][0]== 88 && matn4[3][1]== 88 && matn4[3][2]== 88 && matn4[3][3]== 88 )|| // linha
  1319. (matn4[0][0]== 88 && matn4[1][0]== 88 && matn4[2][0]== 88 && matn4[3][0]== 88 )|| // coluna
  1320. (matn4[0][1]== 88 && matn4[1][1]== 88 && matn4[2][1]== 88 && matn4[3][1]== 88 )|| // coluna
  1321. (matn4[0][2]== 88 && matn4[1][2]== 88 && matn4[2][2]== 88 && matn4[3][2]== 88 )|| // coluna
  1322. (matn4[0][3]== 88 && matn4[1][3]== 88 && matn4[2][3]== 88 && matn4[3][3]== 88 )|| // coluna
  1323. (matn4[0][0]== 88 && matn4[1][1]== 88 && matn4[2][2]== 88 && matn4[3][3]== 88 )|| // diagonal
  1324. (matn4[3][0]== 88 && matn4[2][1]== 88 && matn4[1][2]== 88 && matn4[0][3]== 88 )) // diagonal
  1325. {
  1326. printf("\t\t\t\t*********************************** \n");
  1327. printf("\t\t\t\t* Parabens player 1 voce venceu!!!*\n");
  1328. printf("\t\t\t\t***********************************\n\n");
  1329. velha.pont1++;
  1330. system("pause");
  1331. return continua();
  1332. }
  1333. if ((matn4[0][0]== 79 && matn4[0][1]== 79 && matn4[0][2]== 79 && matn4[0][3]== 79 )|| // linha
  1334. (matn4[1][0]== 79 && matn4[1][1]== 79 && matn4[1][2]== 79 && matn4[1][3]== 79 )|| // linha
  1335. (matn4[2][0]== 79 && matn4[2][1]== 79 && matn4[2][2]== 79 && matn4[2][3]== 79 )|| // linha
  1336. (matn4[3][0]== 79 && matn4[3][1]== 79 && matn4[3][2]== 79 && matn4[3][3]== 79 )|| // linha
  1337. (matn4[0][0]== 79 && matn4[1][0]== 79 && matn4[2][0]== 79 && matn4[3][0]== 79 )|| // coluna
  1338. (matn4[0][1]== 79 && matn4[1][1]== 79 && matn4[2][1]== 79 && matn4[3][1]== 79 )|| // coluna
  1339. (matn4[0][2]== 79 && matn4[1][2]== 79 && matn4[2][2]== 79 && matn4[3][2]== 79 )|| // coluna
  1340. (matn4[0][3]== 79 && matn4[1][3]== 79 && matn4[2][3]== 79 && matn4[3][3]== 79 )|| // coluna
  1341. (matn4[0][0]== 79 && matn4[1][1]== 79 && matn4[2][2]== 79 && matn4[3][3]== 79 )|| // diagonal
  1342. (matn4[3][0]== 79 && matn4[2][1]== 79 && matn4[1][2]== 79 && matn4[0][3]== 79 )) // diagonal
  1343. {
  1344. printf("\t\t\t\t*********************************** \n");
  1345. printf("\t\t\t\t* Parabens player 2 voce venceu!!!*\n");
  1346. printf("\t\t\t\t***********************************\n\n");
  1347. velha.pont2++;
  1348. system("pause");
  1349. return continua();
  1350. }
  1351. if ((matn4[0][0]== 30 && matn4[0][1]== 30 && matn4[0][2]== 30 && matn4[0][3]== 30 )|| // linha
  1352. (matn4[1][0]== 30 && matn4[1][1]== 30 && matn4[1][2]== 30 && matn4[1][3]== 30 )|| // linha
  1353. (matn4[2][0]== 30 && matn4[2][1]== 30 && matn4[2][2]== 30 && matn4[2][3]== 30 )|| // linha
  1354. (matn4[3][0]== 30 && matn4[3][1]== 30 && matn4[3][2]== 30 && matn4[3][3]== 30 )|| // linha
  1355. (matn4[0][0]== 30 && matn4[1][0]== 30 && matn4[2][0]== 30 && matn4[3][0]== 30 )|| // coluna
  1356. (matn4[0][1]== 30 && matn4[1][1]== 30 && matn4[2][1]== 30 && matn4[3][1]== 30 )|| // coluna
  1357. (matn4[0][2]== 30 && matn4[1][2]== 30 && matn4[2][2]== 30 && matn4[3][2]== 30 )|| // coluna
  1358. (matn4[0][3]== 30 && matn4[1][3]== 30 && matn4[2][3]== 30 && matn4[3][3]== 30 )|| // coluna
  1359. (matn4[0][0]== 30 && matn4[1][1]== 30 && matn4[2][2]== 30 && matn4[3][3]== 30 )|| // diagonal
  1360. (matn4[3][0]== 30 && matn4[2][1]== 30 && matn4[1][2]== 30 && matn4[0][3]== 30 )) // diagonal
  1361. {
  1362. printf("\t\t\t\t*********************************** \n");
  1363. printf("\t\t\t\t* Parabens player 3 voce venceu!!!*\n");
  1364. printf("\t\t\t\t***********************************\n\n");
  1365. velha.pont3++;
  1366. system("pause");
  1367. return continua();
  1368. }
  1369. if(cont1==68){
  1370. printf("\n\nEMPATE\n\n");
  1371. system("pause");
  1372. return continua();}
  1373. break;// break do caso 5
  1374. } //chave do switch
  1375.  
  1376. if((matn4[3][0]== 88 && matn3[3][0]== 88 && matn4[3][0]== 88 && matn1[3][0]== 88 )|| //colunaface // Teste para saber se ganhou
  1377. (matn4[3][1]== 88 && matn3[3][1]== 88 && matn1[3][1]== 88 && matn1[3][1]== 88 )|| //colunaface
  1378. (matn4[3][2]== 88 && matn3[3][2]== 88 && matn2[3][2]== 88 && matn1[3][2]== 88 )|| //colunaface
  1379. (matn4[3][3]== 88 && matn3[3][3]== 88 && matn2[3][3]== 88 && matn1[3][3]== 88 )|| //colunaface
  1380. (matn4[2][0]== 88 && matn3[2][0]== 88 && matn2[2][0]== 88 && matn1[2][0]== 88 )|| //colunaface
  1381. (matn4[2][1]== 88 && matn3[2][1]== 88 && matn2[2][1]== 88 && matn1[2][1]== 88 )|| //colunaface
  1382. (matn4[2][2]== 88 && matn3[2][2]== 88 && matn2[2][2]== 88 && matn1[2][2]== 88 )|| //colunaface
  1383. (matn4[2][3]== 88 && matn3[2][3]== 88 && matn2[2][3]== 88 && matn1[2][3]== 88 )|| //colunaface
  1384. (matn4[1][0]== 88 && matn3[1][0]== 88 && matn2[1][0]== 88 && matn1[1][0]== 88 )|| //colunaface
  1385. (matn4[1][1]== 88 && matn3[1][1]== 88 && matn2[1][1]== 88 && matn1[1][1]== 88 )|| //colunaface
  1386. (matn4[1][2]== 88 && matn3[1][2]== 88 && matn2[1][2]== 88 && matn1[1][2]== 88 )|| //colunaface
  1387. (matn4[1][3]== 88 && matn3[1][3]== 88 && matn2[1][3]== 88 && matn1[1][3]== 88 )|| //colunaface
  1388. (matn4[0][0]== 88 && matn3[0][0]== 88 && matn2[0][0]== 88 && matn1[0][0]== 88 )|| //colunaface
  1389. (matn4[0][1]== 88 && matn3[0][1]== 88 && matn2[0][1]== 88 && matn1[0][1]== 88 )|| //colunaface
  1390. (matn4[0][2]== 88 && matn3[0][2]== 88 && matn2[0][2]== 88 && matn1[0][2]== 88 )|| //colunaface
  1391. (matn4[0][3]== 88 && matn3[0][3]== 88 && matn2[0][3]== 88 && matn1[0][3]== 88 )|| //colunaface
  1392. (matn4[0][2]== 88 && matn3[0][2]== 88 && matn2[0][2]== 88 && matn1[0][2]== 88 )|| //colunaface
  1393. (matn4[3][0]== 88 && matn3[3][1]== 88 && matn2[3][2]== 88 && matn1[3][3]== 88 )|| // \ diagonalface1
  1394. (matn4[3][3]== 88 && matn3[3][2]== 88 && matn2[3][1]== 88 && matn1[3][0]== 88 )|| // / giagonalface1
  1395. (matn4[2][0]== 88 && matn3[2][1]== 88 && matn2[2][2]== 88 && matn1[2][3]== 88 )|| // \ diagonalface2
  1396. (matn4[2][3]== 88 && matn3[2][2]== 88 && matn2[2][1]== 88 && matn1[2][0]== 88 )|| // / giagonalface2
  1397. (matn4[1][0]== 88 && matn3[1][1]== 88 && matn2[1][2]== 88 && matn1[1][3]== 88 )|| // \ diagonalface3
  1398. (matn4[1][3]== 88 && matn3[1][2]== 88 && matn2[1][1]== 88 && matn1[1][0]== 88 )|| // \ diagonalface3
  1399. (matn4[0][0]== 88 && matn3[0][1]== 88 && matn2[0][2]== 88 && matn1[0][3]== 88 )|| // \ diagonalface4
  1400. (matn4[0][3]== 88 && matn3[0][2]== 88 && matn2[0][1]== 88 && matn1[0][0]== 88 )|| // \ diagonalface4
  1401. (matn4[3][0]== 88 && matn3[2][1]== 88 && matn2[1][2]== 88 && matn1[0][3]== 88 )|| //diagonalcubo
  1402. (matn4[3][3]== 88 && matn3[2][2]== 88 && matn2[1][1]== 88 && matn1[0][0]== 88 )|| //diagonalcubo
  1403. (matn4[0][0]== 88 && matn3[1][1]== 88 && matn2[2][2]== 88 && matn1[3][3]== 88 )|| //diagonalcubo
  1404. (matn4[0][3]== 88 && matn3[1][2]== 88 && matn2[2][1]== 88 && matn1[3][0]== 88 )) //diagonalcubo
  1405. {
  1406. printf("\t\t\t\t*********************************** \n");
  1407. printf("\t\t\t\t* Parabens player 1 voce venceu!!!*\n");
  1408. printf("\t\t\t\t***********************************\n\n");
  1409. velha.pont1++;
  1410. system("pause");
  1411. return continua();
  1412. }
  1413. if((matn4[3][0]== 79 && matn3[3][0]== 79 && matn4[3][0]== 79 && matn1[3][0]== 79 )|| //colunaface // Teste para saber se ganhou
  1414. (matn4[3][1]== 79 && matn3[3][1]== 79 && matn1[3][1]== 79 && matn1[3][1]== 79 )|| //colunaface
  1415. (matn4[3][2]== 79 && matn3[3][2]== 79 && matn2[3][2]== 79 && matn1[3][2]== 79 )|| //colunaface
  1416. (matn4[3][3]== 79 && matn3[3][3]== 79 && matn2[3][3]== 79 && matn1[3][3]== 79 )|| //colunaface
  1417. (matn4[2][0]== 79 && matn3[2][0]== 79 && matn2[2][0]== 79 && matn1[2][0]== 79 )|| //colunaface
  1418. (matn4[2][1]== 79 && matn3[2][1]== 79 && matn2[2][1]== 79 && matn1[2][1]== 79 )|| //colunaface
  1419. (matn4[2][2]== 79 && matn3[2][2]== 79 && matn2[2][2]== 79 && matn1[2][2]== 79 )|| //colunaface
  1420. (matn4[2][3]== 79 && matn3[2][3]== 79 && matn2[2][3]== 79 && matn1[2][3]== 79 )|| //colunaface
  1421. (matn4[1][0]== 79 && matn3[1][0]== 79 && matn2[1][0]== 79 && matn1[1][0]== 79 )|| //colunaface
  1422. (matn4[1][1]== 79 && matn3[1][1]== 79 && matn2[1][1]== 79 && matn1[1][1]== 79 )|| //colunaface
  1423. (matn4[1][2]== 79 && matn3[1][2]== 79 && matn2[1][2]== 79 && matn1[1][2]== 79 )|| //colunaface
  1424. (matn4[1][3]== 79 && matn3[1][3]== 79 && matn2[1][3]== 79 && matn1[1][3]== 79 )|| //colunaface
  1425. (matn4[0][0]== 79 && matn3[0][0]== 79 && matn2[0][0]== 79 && matn1[0][0]== 79 )|| //colunaface
  1426. (matn4[0][1]== 79 && matn3[0][1]== 79 && matn2[0][1]== 79 && matn1[0][1]== 79 )|| //colunaface
  1427. (matn4[0][2]== 79 && matn3[0][2]== 79 && matn2[0][2]== 79 && matn1[0][2]== 79 )|| //colunaface
  1428. (matn4[0][3]== 79 && matn3[0][3]== 79 && matn2[0][3]== 79 && matn1[0][3]== 79 )|| //colunaface
  1429. (matn4[0][2]== 79 && matn3[0][2]== 79 && matn2[0][2]== 79 && matn1[0][2]== 79 )|| //colunaface
  1430. (matn4[3][0]== 79 && matn3[3][1]== 79 && matn2[3][2]== 79 && matn1[3][3]== 79 )|| // \ diagonalface1
  1431. (matn4[3][3]== 79 && matn3[3][2]== 79 && matn2[3][1]== 79 && matn1[3][0]== 79 )|| // / giagonalface1
  1432. (matn4[2][0]== 79 && matn3[2][1]== 79 && matn2[2][2]== 79 && matn1[2][3]== 79 )|| // \ diagonalface2
  1433. (matn4[2][3]== 79 && matn3[2][2]== 79 && matn2[2][1]== 79 && matn1[2][0]== 79 )|| // / giagonalface2
  1434. (matn4[1][0]== 79 && matn3[1][1]== 79 && matn2[1][2]== 79 && matn1[1][3]== 79 )|| // \ diagonalface3
  1435. (matn4[1][3]== 79 && matn3[1][2]== 79 && matn2[1][1]== 79 && matn1[1][0]== 79 )|| // \ diagonalface3
  1436. (matn4[0][0]== 79 && matn3[0][1]== 79 && matn2[0][2]== 79 && matn1[0][3]== 79 )|| // \ diagonalface4
  1437. (matn4[0][3]== 79 && matn3[0][2]== 79 && matn2[0][1]== 79 && matn1[0][0]== 79 )|| // \ diagonalface4
  1438. (matn4[3][0]== 79 && matn3[2][1]== 79 && matn2[1][2]== 79 && matn1[0][3]== 79 )|| //diagonalcubo
  1439. (matn4[3][3]== 79 && matn3[2][2]== 79 && matn2[1][1]== 79 && matn1[0][0]== 79 )|| //diagonalcubo
  1440. (matn4[0][0]== 79 && matn3[1][1]== 79 && matn2[2][2]== 79 && matn1[3][3]== 79 )|| //diagonalcubo
  1441. (matn4[0][3]== 79 && matn3[1][2]== 79 && matn2[2][1]== 79 && matn1[3][0]== 79 )) //diagonalcubo
  1442. {
  1443. printf("\t\t\t\t*********************************** \n");
  1444. printf("\t\t\t\t* Parabens player 2 voce venceu!!!*\n");
  1445. printf("\t\t\t\t***********************************\n\n");
  1446. velha.pont2++;
  1447. system("pause");
  1448. return continua();
  1449. }
  1450. if((matn4[3][0]== 30 && matn3[3][0]== 30 && matn4[3][0]== 30 && matn1[3][0]== 30 )|| //colunaface // Teste para saber se ganhou
  1451. (matn4[3][1]== 30 && matn3[3][1]== 30 && matn1[3][1]== 30 && matn1[3][1]== 30 )|| //colunaface
  1452. (matn4[3][2]== 30 && matn3[3][2]== 30 && matn2[3][2]== 30 && matn1[3][2]== 30 )|| //colunaface
  1453. (matn4[3][3]== 30 && matn3[3][3]== 30 && matn2[3][3]== 30 && matn1[3][3]== 30 )|| //colunaface
  1454. (matn4[2][0]== 30 && matn3[2][0]== 30 && matn2[2][0]== 30 && matn1[2][0]== 30 )|| //colunaface
  1455. (matn4[2][1]== 30 && matn3[2][1]== 30 && matn2[2][1]== 30 && matn1[2][1]== 30 )|| //colunaface
  1456. (matn4[2][2]== 30 && matn3[2][2]== 30 && matn2[2][2]== 30 && matn1[2][2]== 30 )|| //colunaface
  1457. (matn4[2][3]== 30 && matn3[2][3]== 30 && matn2[2][3]== 30 && matn1[2][3]== 30 )|| //colunaface
  1458. (matn4[1][0]== 30 && matn3[1][0]== 30 && matn2[1][0]== 30 && matn1[1][0]== 30 )|| //colunaface
  1459. (matn4[1][1]== 30 && matn3[1][1]== 30 && matn2[1][1]== 30 && matn1[1][1]== 30 )|| //colunaface
  1460. (matn4[1][2]== 30 && matn3[1][2]== 30 && matn2[1][2]== 30 && matn1[1][2]== 30 )|| //colunaface
  1461. (matn4[1][3]== 30 && matn3[1][3]== 30 && matn2[1][3]== 30 && matn1[1][3]== 30 )|| //colunaface
  1462. (matn4[0][0]== 30 && matn3[0][0]== 30 && matn2[0][0]== 30 && matn1[0][0]== 30 )|| //colunaface
  1463. (matn4[0][1]== 30 && matn3[0][1]== 30 && matn2[0][1]== 30 && matn1[0][1]== 30 )|| //colunaface
  1464. (matn4[0][2]== 30 && matn3[0][2]== 30 && matn2[0][2]== 30 && matn1[0][2]== 30 )|| //colunaface
  1465. (matn4[0][3]== 30 && matn3[0][3]== 30 && matn2[0][3]== 30 && matn1[0][3]== 30 )|| //colunaface
  1466. (matn4[0][2]== 30 && matn3[0][2]== 30 && matn2[0][2]== 30 && matn1[0][2]== 30 )|| //colunaface
  1467. (matn4[3][0]== 30 && matn3[3][1]== 30 && matn2[3][2]== 30 && matn1[3][3]== 30 )|| // \ diagonalface1
  1468. (matn4[3][3]== 30 && matn3[3][2]== 30 && matn2[3][1]== 30 && matn1[3][0]== 30 )|| // / giagonalface1
  1469. (matn4[2][0]== 30 && matn3[2][1]== 30 && matn2[2][2]== 30 && matn1[2][3]== 30 )|| // \ diagonalface2
  1470. (matn4[2][3]== 30 && matn3[2][2]== 30 && matn2[2][1]== 30 && matn1[2][0]== 30 )|| // / giagonalface2
  1471. (matn4[1][0]== 30 && matn3[1][1]== 30 && matn2[1][2]== 30 && matn1[1][3]== 30 )|| // \ diagonalface3
  1472. (matn4[1][3]== 30 && matn3[1][2]== 30 && matn2[1][1]== 30 && matn1[1][0]== 30 )|| // \ diagonalface3
  1473. (matn4[0][0]== 30 && matn3[0][1]== 30 && matn2[0][2]== 30 && matn1[0][3]== 30 )|| // \ diagonalface4
  1474. (matn4[0][3]== 30 && matn3[0][2]== 30 && matn2[0][1]== 30 && matn1[0][0]== 30 )|| // \ diagonalface4
  1475. (matn4[3][0]== 30 && matn3[2][1]== 30 && matn2[1][2]== 30 && matn1[0][3]== 30 )|| //diagonalcubo
  1476. (matn4[3][3]== 30 && matn3[2][2]== 30 && matn2[1][1]== 30 && matn1[0][0]== 30 )|| //diagonalcubo
  1477. (matn4[0][0]== 30 && matn3[1][1]== 30 && matn2[2][2]== 30 && matn1[3][3]== 30 )|| //diagonalcubo
  1478. (matn4[0][3]== 30 && matn3[1][2]== 30 && matn2[2][1]== 30 && matn1[3][0]== 30 )) //diagonalcubo
  1479. {
  1480. printf("\t\t\t\t*********************************** \n");
  1481. printf("\t\t\t\t* Parabens player 3 voce venceu!!!*\n");
  1482. printf("\t\t\t\t***********************************\n\n");
  1483. velha.pont3++;
  1484. system("pause");
  1485. return continua();
  1486. }
  1487. if(cont1==68){
  1488. printf("\n\nEMPATE\n\n");
  1489. system("pause");
  1490. return continua();}
  1491. andarn4();
  1492. andarn3();
  1493. andarn2();
  1494. andarn1();
  1495. cont1++; // contador para o primeiro if else
  1496. }
  1497. while (cont1<68);
  1498. return continua();
  1499. }
  1500. void tutorial(){ /** Tutorial **/
  1501.  
  1502. printf ("\t\t\t .----------------------. \n");
  1503. printf ("\t\t\t | ** TUTORIAL ** | \n");
  1504. printf ("\t\t\t `----------------------' \n\n");
  1505. printf (" \t\t\t--- Regras: ---\n\n");
  1506. printf (" - Este Jogo da Velha tem 3 opcoes disponiveis: Tabuleiro com 3 camadas, \n");
  1507. printf (" tabuleiro com 4 camadas para 2 jogadores e tabuleiro com 4 camadas para 3 jogadores. \n");
  1508. printf (" - O jogo se desenvolve com os jogadores marcando as quasas de qualquer camada. \n");
  1509. printf (" - Eh possivel pontuar marcando 3 casas na horizontal, na vertical, na diagonal e\n");
  1510. printf (" nas linhas em 3D, quando um jogador pontua marcando em casas diferentes.\n\n");
  1511. printf (" - No caso dos tabuleiros com 3 camadas o jogo so acaba quando todas as casas\n");
  1512. printf (" estiverem preenchidas. Ja no tabuleiro com 4 camadas, o jogo acaba quando qualquer");
  1513. printf (" um dos jogadores pontuar!\n");
  1514. system("pause");
  1515. menu();
  1516.  
  1517. }
  1518. int menu(void)
  1519. {
  1520. system ("color 30");
  1521. int opcao, op1, tab;
  1522. char jogador;
  1523. system("cls");
  1524.  
  1525. printf("\t\t\t __ __ \n");
  1526. printf("\t\t\t| \\/ | \n");
  1527. printf("\t\t\t| \\ / | __ _ __ _ _ \n");
  1528. printf("\t\t\t| |\\/| |/ _\\ '_ \\| | | |\n");
  1529. printf("\t\t\t| | | | __/ | | | |_| |\n");
  1530. printf("\t\t\t|_| |_|\___|_| |_|\\\__,_|\n");
  1531. printf("\n\n");
  1532.  
  1533. do{
  1534. printf ("\t\t\t .-----------------------. \n");
  1535. printf ("\t\t\t | * * | \n");
  1536. printf ("\t\t\t | 1 - NOVO JOGO | \n");
  1537. printf ("\t\t\t | 2 - SCORES | \n");
  1538. printf ("\t\t\t | 3 - TUTORIAL | \n");
  1539. printf ("\t\t\t | 4 - SAIR | \n");
  1540. printf ("\t\t\t | * * | \n");
  1541. printf ("\t\t\t `-----------------------' \n\n\n\n\n");
  1542. scanf("%d", &opcao);
  1543. }while(opcao != 1 && opcao != 2 && opcao != 3 && opcao != 4);
  1544. switch(opcao)
  1545. {
  1546. case 1:
  1547. do
  1548. {
  1549. system("cls");
  1550. system ("color 30");
  1551. printf ("\t\t .----------------------------------. \n");
  1552. printf ("\t\t | ** NIVEL DE DIFICULDADE ** | \n");
  1553. printf ("\t\t `----------------------------------' \n\n");
  1554. printf("\t\t\t1 - Para tabuleiro com 3 camadas\n");
  1555. printf("\n");
  1556. printf("\t\t\t2 - Para tabuleiro com 4 camadas\n");
  1557. scanf("%d", &tab);
  1558. }
  1559. while(tab!=1 && tab!=2);
  1560. system("cls");
  1561. system("color 30");
  1562. if(tab==1){
  1563. cadastro();
  1564. system ("cls");
  1565. system ("color 30");
  1566. funcaojogo();
  1567. }
  1568. if(tab==2){
  1569. system("cls");
  1570. system ("color 30");
  1571. do{
  1572. printf ("\t\t .----------------------------------. \n");
  1573. printf ("\t\t | ** Quantidade de Jogadores ** | \n");
  1574. printf ("\t\t `----------------------------------' \n\n");
  1575. printf("\t\t\t1- Para dois jogadores;\n");
  1576. printf("\n");
  1577. printf("\t\t\t2- Para tres jogadores;\n");
  1578. scanf("%d", &jogador);
  1579. }while(jogador != 1 && jogador !=2);
  1580. if(jogador==1){
  1581. system("cls");
  1582. system("color 30");
  1583. cadastro();
  1584. system ("cls");
  1585. system ("color 30");
  1586. jogo();
  1587. }
  1588. if(jogador==2){
  1589. system("cls");
  1590. system("color 30");
  1591. cadastro3();
  1592. system ("cls");
  1593. system ("color 30");
  1594. jogo1();
  1595. }
  1596. }
  1597. break;
  1598. case 2:
  1599. system("cls");
  1600. system("color30");
  1601. escreve();
  1602. break;
  1603. case 3:
  1604. system("cls");
  1605. tutorial();
  1606.  
  1607. break;
  1608. case 4:
  1609. exit("menu");
  1610. break;
  1611. default:
  1612. system("pause");
  1613. printf("Opcao invalida. Tente de novo!\n");
  1614. }
  1615. return opcao;
  1616. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement