Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <ctype.h>
- #include <windows.h>
- /*declaração de funções*/
- void apresentacao();
- int menu(void);
- void funcaojogo();
- void jogo();
- void jogo1();
- void andar1 (void);
- void andar2 (void);
- void andar2 (void);
- int andarn1 ();
- int andarn2 ();
- int andarn3 ();
- int andarn4 ();
- void continua (void);
- void tutorial (void);
- int main (void){
- system("color 30");
- apresentacao();
- menu();
- system("PAUSE");
- return 0;
- }
- void apresentacao(){ /** Introdução **/
- Sleep(2000);
- printf("\n\n\n\n\n\n\n");
- printf("\t\t _ _ _ \n");
- printf("\t\t| | (_) | | \n");
- printf("\t\t| |__ ___ _ __ ___ __ ___ _ __ __| | ___ \n");
- printf("\t\t| '_ \\ / _ \\\ '_ ` _ \\ \\ \\ / / | '_ \\ / _` |/ _ \\ \n");
- printf("\t\t| |_) | __/ | | | | | \\ V /| | | | | (_| | (_) |\n");
- printf("\t\t|_.__/ \\___|_| |_| |_| \\_/ |_|_| |_|\\__,_|\\___/ \n");
- printf("\n\n\n\n");
- Sleep(2000);
- system("cls");
- printf("\n\n\n\n\n\n");
- printf("\t _ _ __ __ _ _ \n");
- printf("\t | | | | \\ \\ / / | | | \n");
- printf("\t | | ___ __ _ ___ __| | __ _ \\ \\ / /__| | |__ __ _ \n");
- printf("\t _ | |/ _ \\ / _` |/ _ \\ / _` |/ _` | \\ \\/ / _ \\ | '_ \\ / _` | \n");
- printf("\t | |__| | (_) | (_| | (_) | | (_| | (_| | \\ / __/ | | | | (_| | \n");
- printf("\t \\____/ \\___/ \\__, |\\___/ \\__,_|\\__,_| \\/ \\___|_|_| |_|\\__,_| \n");
- printf("\t __/ | \n");
- printf("\t |___/ \n");
- Sleep(500);
- printf("\n\n");
- system("pause");
- }
- void continua(){
- int opc;
- system ("cls");
- do{
- printf("\t\t\t\tO que deseja fazer?\n(1)Voltar ao Menu.\n(2)Jogar Novamente.\n(3)Sair.\n");
- scanf("%d", &opc);
- }while(opc!=1 && opc!=2 && opc!=3);
- switch(opc){
- case 1:
- menu();
- case 2:
- funcaojogo();
- case 3:
- funcaojogo();
- break;
- }
- }
- struct jogadores
- {
- char player1[20],player2[20], player3[20];
- int pont1,pont2, pont3;
- } velha;
- FILE*players,*ranking;
- struct jogadores velha;
- void registro()
- {
- system ("cls");
- fwrite(&velha, sizeof(velha), 1, players);
- fwrite(&velha, sizeof(velha), 1, ranking);
- }
- void escreve ()
- {
- system ("cls");
- int opc;
- rewind(players);
- while(fread(&velha, sizeof(velha), 1, players)==1);
- do{
- printf ("\t\t\t .-------------------------------. \n");
- printf ("\t\t\t | ** SCORES ** | \n");
- printf ("\t\t\t `-------------------------------' \n\n");
- printf ("\t\t\t 1 - Ver score do tabuleiro de 3 camadas.\n");
- printf ("\t\t\t 2 - Ver score do tabuleiro de 4 camadas.\n");
- printf ("\t\t\t 3 - Voltar ao menu.\n");
- scanf ("\t\t\t%d",&opc);
- } while (opc!=1 && opc!=2 && opc!=3);
- switch (opc) {
- case 1:
- system("cls");
- printf ("\t\t\t .-------------------------------. \n");
- printf ("\t\t\t | ** SCORES ** | \n");
- printf ("\t\t\t `-------------------------------' \n\n");
- printf ("\t\t\t Jogador\t\t\tPontos\n\n");
- printf ("\t\t\t %s\t\t\t%d\n", velha.player1, velha.pont1);
- printf ("\t\t\t %s\t\t\t%d\n", velha.player2, velha.pont2);
- system("pause");
- menu();
- case 2:
- system("cls");
- printf ("\t\t\t .-------------------------------. \n");
- printf ("\t\t\t | ** SCORES ** | \n");
- printf ("\t\t\t `-------------------------------' \n\n");
- printf ("\t\t\t Jogador\t\t\tPontos\n\n");
- printf ("\t\t\t %s\t\t\t%d\n", velha.player1, velha.pont1);
- printf ("\t\t\t %s\t\t\t%d\n", velha.player2, velha.pont2);
- printf ("\t\t\t %s\t\t\t%d\n", velha.player3, velha.pont3);
- system("pause");
- menu();
- case 3:
- system("cls");
- menu();
- }
- }
- void cadastro ()
- {
- int opcao;
- players=fopen("players.txt","a");
- if (players == NULL) //verifica se teve algo escrito no arquivo, caso nao ele ira voltar pro menu
- {
- printf("NAO FOI POSSIVEL ABRIR O ARQUIVO.\n");
- getchar();
- system("pause");
- menu();
- }
- do{
- system("cls");
- printf ("\t\t\t .----------------------. \n");
- printf ("\t\t\t | ** CADASTRO ** | \n");
- printf ("\t\t\t `----------------------' \n\n");
- printf("\n");
- printf("\t1 - Cadastrar novo jogador;\n");
- printf("\t2 - Voltar ao menu;\n");
- scanf("%d", &opcao);
- }while(opcao != 1 && opcao != 2 );
- system("cls");
- switch(opcao){
- case 1:
- printf ("\t\t\t .----------------------. \n");
- printf ("\t\t\t | ** JOGADORES ** | \n");
- printf ("\t\t\t `----------------------' \n\n");
- printf("Nome do Jogador 'X':\n");
- scanf("%s", &velha.player1);
- printf("Nome do jogador 'O':\n");
- scanf("%s",&velha.player2);
- registro();
- funcaojogo();
- case 2:
- menu();
- }
- }
- void cadastro3(){
- int opcao;
- players=fopen("players.txt","a");
- if (players == NULL) //verifica se teve algo escrito no arquivo, caso nao ele ira voltar pro menu
- {
- printf("NAO FOI POSSIVEL ABRIR O ARQUIVO.\n");
- getchar();
- system("pause");
- menu();
- }
- do{
- system("cls");
- printf ("\t\t\t .----------------------. \n");
- printf ("\t\t\t | ** CADASTRO ** | \n");
- printf ("\t\t\t `----------------------' \n\n");
- printf("\n");
- printf("\t1 - Cadastrar novo jogador;\n");
- printf("\t2 - Voltar ao menu;\n");
- scanf("%d", &opcao);
- }while(opcao != 1 && opcao != 2 );
- system("cls");
- switch(opcao){
- case 1:
- printf ("\t\t\t .----------------------. \n");
- printf ("\t\t\t | ** JOGADORES ** | \n");
- printf ("\t\t\t `----------------------' \n\n");
- printf("Nome do Jogador 'X':\n");
- scanf("%s", &velha.player1);
- printf("Nome do jogador 'O':\n");
- scanf("%s",&velha.player2);
- printf("Nome do Jogador '':\n");
- scanf("%s", &velha.player3);
- registro();
- jogo1();
- case 2:
- menu();
- }
- }
- void funcaojogo () // funcao para rodar o jogo 3x3x3
- {
- ranking=fopen("ranking.txt","w");
- char mat1[3][3];
- char mat2[3][3];
- char mat3[3][3];
- int q;
- int i=0,j=0,k=0,m=0,aux1,cont1=2,aux2;
- void andar3(){
- printf(" 3 andar\n");
- printf("\n %c| %c| %c\n",mat3[0][0],mat3[0][1],mat3[0][2]); // Printar o tabuleiro
- printf("___________\n"); // Printar o tabuleiro
- printf(" %c| %c| %c\n",mat3[1][0],mat3[1][1],mat3[1][2]); // Printar o tabuleiro
- printf("___________\n"); // Printar o tabuleiro
- printf(" %c| %c| %c\n",mat3[2][0],mat3[2][1],mat3[2][2]); // Printar o tabuleiro
- printf(" \n");
- }
- void andar2(){
- printf(" 2 andar\n");
- printf("\n %c| %c| %c\n",mat2[0][0],mat2[0][1],mat2[0][2]); // Printar o tabuleiro
- printf("___________\n"); // Printar o tabuleiro
- printf(" %c| %c| %c\n",mat2[1][0],mat2[1][1],mat2[1][2]); // Printar o tabuleiro
- printf("___________\n"); // Printar o tabuleiro
- printf(" %c| %c| %c\n",mat2[2][0],mat2[2][1],mat2[2][2]); // Printar o tabuleiro
- printf(" \n ");
- }
- void andar1(){
- printf(" 1 andar\n");
- printf("\n %c| %c| %c\n",mat1[0][0],mat1[0][1],mat1[0][2]); // Printar o tabuleiro
- printf("___________\n"); // Printar o tabuleiro
- printf(" %c| %c| %c\n",mat1[1][0],mat1[1][1],mat1[1][2]); // Printar o tabuleiro
- printf("___________\n"); // Printar o tabuleiro
- printf(" %c| %c| %c\n",mat1[2][0],mat1[2][1],mat1[2][2]); // Printar o tabuleiro
- printf(" \n \n \n ");
- printf(" \n\n");
- }
- for(i=0; i < 3; i++){ // preenchimento da matriz com ' '
- for(j=0; j < 3; j++){ //preenche todas a posição com ' '
- mat1[i][j]=' ';
- mat2[i][j]=' ';
- mat3[i][j]=' ';
- } // SEGUNDO LACO FOR
- } // PRIMEIRO LACO FOR
- andar3();//Printar TABULEIRO
- andar2();
- andar1();
- do // De onde o jogo de desenvolve
- {
- if (cont1 % 2 == 0) // SE FOR 0, q=88; SERÁ O JOGADOR 1, SE FOR q=79;, JOGADOR 2
- q=88;
- else
- q=79;
- do // Para escolher o andar
- {
- printf("Escolha o andar: 1,2 ou 3:\n");
- scanf("%d", &aux1);
- if(aux1==1){
- if((mat1[0][0]==88 || mat1[0][0]==79) && //primeiro andar preenchido
- (mat1[0][1]==88 || mat1[0][1]==79) && //primeiro andar preenchido
- (mat1[0][2]==88 || mat1[0][2]==79) && //primeiro andar preenchido
- (mat1[1][0]==88 || mat1[1][0]==79) && //primeiro andar preenchido
- (mat1[1][1]==88 || mat1[1][1]==79) && //primeiro andar preenchido
- (mat1[1][2]==88 || mat1[1][2]==79) && //primeiro andar preenchido
- (mat1[2][0]==88 || mat1[2][0]==79) && //primeiro andar preenchido
- (mat1[2][1]==88 || mat1[2][1]==79) && //primeiro andar preenchido
- (mat1[2][2]==88 || mat1[2][2]==79)) //primeiro andar preenchido
- { // chave do if
- do{
- printf("ANDAR 1 PREENCHIDO!\nEscolha o andar disponivel: 2 ou 3:\n");
- scanf("%d", &aux1);} while((aux1 != 2) && (aux1 != 3));
- }
- } //chave do if
- if(aux1==2){
- if((mat2[0][0]==88 || mat2[0][0]==79) && //Verificar segundo andar preenchido
- (mat2[0][1]==88 || mat2[0][1]==79) && //Verificar segundo andar preenchido
- (mat2[0][2]==88 || mat2[0][2]==79) && //Verificar segundo andar preenchido
- (mat2[1][0]==88 || mat2[1][0]==79) && //Verificar segundo andar preenchido
- (mat2[1][1]==88 || mat2[1][1]==79) && //Verificar segundo andar preenchido
- (mat2[1][2]==88 || mat2[1][2]==79) && //Verificar segundo andar preenchido
- (mat2[2][0]==88 || mat2[2][0]==79) && //Verificar segundo andar preenchido
- (mat2[2][1]==88 || mat2[2][1]==79) && //Verificar segundo andar preenchido
- (mat2[2][2]==88 || mat2[2][2]==79)) //Verificar segundo andar preenchido
- {
- do{
- printf("ANDAR 2 PREENCHIDO!\nEscolha o andar disponivel: 1 ou 3:\n");
- scanf("%d", &aux1);} while((aux1 != 1) && (aux1 != 3));
- }// chave do if
- }
- if(aux1==3){
- if((mat3[0][0]==88 || mat3[0][0]==79) && //Verificar terceiro andar preenchido
- (mat3[0][1]==88 || mat3[0][1]==79) && //Verificar terceiro andar preenchido
- (mat3[0][2]==88 || mat3[0][2]==79) && //Verificar terceiro andar preenchido
- (mat3[1][0]==88 || mat3[1][0]==79) && //Verificar terceiro andar preenchido
- (mat3[1][1]==88 || mat3[1][1]==79) && //Verificar terceiro andar preenchido
- (mat3[1][2]==88 || mat3[1][2]==79) && //Verificar terceiro andar preenchido
- (mat3[2][0]==88 || mat3[2][0]==79) && //Verificar terceiro andar preenchido
- (mat3[2][1]==88 || mat3[2][1]==79) && //Verificar terceiro andar preenchido
- (mat3[2][2]==88 || mat3[2][2]==79)) //Verificar terceiro andar preenchido
- {
- do{
- printf("ANDAR 3 PREENCHIDO!\nEscolha o andar disponivel: 1 ou 2:\n");
- scanf("%d", &aux1);} while((aux1 != 1) && (aux1 != 2));
- }//chave do if
- }
- } while((aux1 != 1) && (aux1 != 2) && (aux1 != 3)); //para Printar somente os andares disponíveis
- switch(aux1) // andar
- {
- case 1 :
- do
- {
- printf("Em qual linha e coluna vc deseja marcar:\n");
- printf("Linha: "); // Preencher o tabuleiro
- scanf("%d",&i); // Preencher o tabuleiro
- printf("Coluna: "); // Preencher o tabuleiro
- scanf("%d",&j); // Preencher o tabuleiro
- system("cls");
- } 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
- mat1[i-1][j-1]= q ; // para marcar x ou O na linha e colina escolhida
- if ((mat1[0][0]==88 && mat1[0][1]==88 && mat1[0][2]==88)|| // Teste para saber se marcou
- (mat1[1][0]==88 && mat1[1][1]==88 && mat1[1][2]==88)|| // Teste para saber se marcou
- (mat1[2][0]==88 && mat1[2][1]==88 && mat1[2][2]==88)|| // Teste para saber se marcou
- (mat1[0][0]==88 && mat1[1][0]==88 && mat1[2][0]==88)|| // Teste para saber se marcou
- (mat1[0][1]==88 && mat1[1][1]==88 && mat1[2][1]==88)|| // Teste para saber se marcou
- (mat1[0][2]==88 && mat1[1][2]==88 && mat1[2][2]==88)|| // Teste para saber se marcou
- (mat1[0][0]==88 && mat1[1][1]==88 && mat1[2][2]==88)|| // Teste para saber se marcou
- (mat1[0][2]==88 && mat1[1][1]==88 && mat1[2][0]==88)) // Teste para saber se marcou
- {
- velha.pont1++;
- }
- if ((mat1[0][0]==79 && mat1[0][1]==79 && mat1[0][2]==79)|| // Teste para saber se marcou
- (mat1[1][0]==79 && mat1[1][1]==79 && mat1[1][2]==79)|| // Teste para saber se marcou
- (mat1[2][0]==79 && mat1[2][1]==79 && mat1[2][2]==79)|| // Teste para saber se marcou
- (mat1[0][0]==79 && mat1[1][0]==79 && mat1[2][0]==79)|| // Teste para saber se marcou
- (mat1[0][1]==79 && mat1[1][1]==79 && mat1[2][1]==79)|| // Teste para saber se marcou
- (mat1[0][2]==79 && mat1[1][2]==79 && mat1[2][2]==79)|| // Teste para saber se marcou
- (mat1[0][0]==79 && mat1[1][1]==79 && mat1[2][2]==79)|| // Teste para saber se marcou
- (mat1[0][2]==79 && mat1[1][1]==79 && mat1[2][0]==79)) // Teste para saber se marcou
- {
- velha.pont2++;
- }
- break; // break do caso 1
- case 2 :
- do
- {
- printf("Em qual linha e coluna vc deseja marcar:\n");
- printf("Linha: "); // Preencher o tabuleiro
- scanf("%d",&i); // Preencher o tabuleiro
- printf("Coluna: "); // Preencher o tabuleiro
- scanf("%d",&j); // Preencher o tabuleiro
- system("cls");
- } 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
- mat2[i-1][j-1]= q ; // para marcar x ou O na linha e colina escolhida
- if ((mat2[0][0]==88 && mat2[0][1]==88 && mat2[0][2]==88)|| // Teste para saber se marcou
- (mat2[1][0]==88 && mat2[1][1]==88 && mat2[1][2]==88)|| // Teste para saber se marcou
- (mat2[2][0]==88 && mat2[2][1]==88 && mat2[2][2]==88)|| // Teste para saber se marcou
- (mat2[0][0]==88 && mat2[1][0]==88 && mat2[2][0]==88)|| // Teste para saber se marcou
- (mat2[0][1]==88 && mat2[1][1]==88 && mat2[2][1]==88)|| // Teste para saber se marcou
- (mat2[0][2]==88 && mat2[1][2]==88 && mat2[2][2]==88)|| // Teste para saber se marcou
- (mat2[0][0]==88 && mat2[1][1]==88 && mat2[2][2]==88)|| // Teste para saber se marcou
- (mat2[0][2]==88 && mat2[1][1]==88 && mat2[2][0]==88)) // Teste para saber se marcou
- {
- velha.pont1++;
- }
- if ((mat2[0][0]==79 && mat2[0][1]==79 && mat2[0][2]==79)|| // Teste para saber se marcou
- (mat2[1][0]==79 && mat2[1][1]==79 && mat2[1][2]==79)|| // Teste para saber se marcou
- (mat2[2][0]==79 && mat2[2][1]==79 && mat2[2][2]==79)|| // Teste para saber se marcou
- (mat2[0][0]==79 && mat2[1][0]==79 && mat2[2][0]==79)|| // Teste para saber se marcou
- (mat2[0][1]==79 && mat2[1][1]==79 && mat2[2][1]==79)|| // Teste para saber se marcou
- (mat2[0][2]==79 && mat2[1][2]==79 && mat2[2][2]==79)|| // Teste para saber se marcou
- (mat2[0][0]==79 && mat2[1][1]==79 && mat2[2][2]==79)|| // Teste para saber se marcou
- (mat2[0][2]==79 && mat2[1][1]==79 && mat2[2][0]==79)) // Teste para saber se marcou
- {
- velha.pont2++;
- }
- break;// break do caso 2
- case 3 :
- do
- {
- printf("Em qual linha e coluna vc deseja marcar.\n");
- printf("Linha: "); // Preencher o tabuleiro
- scanf("%d",&i); // Preencher o tabuleiro
- printf("Coluna: "); // Preencher o tabuleiro
- scanf("%d",&j); // Preencher o tabuleiro
- system("cls");
- } 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
- mat3[i-1][j-1]= q ; // para marcar x ou O na linha e colina escolhida
- if((mat3[0][0]==88 && mat3[0][1]==88 && mat3[0][2]==88)|| // Teste para saber se marcou
- (mat3[1][0]==88 && mat3[1][1]==88 && mat3[1][2]==88)|| // Teste para saber se marcou
- (mat3[2][0]==88 && mat3[2][1]==88 && mat3[2][2]==88)|| // Teste para saber se marcou
- (mat3[0][0]==88 && mat3[1][0]==88 && mat3[2][0]==88)|| // Teste para saber se marcou
- (mat3[0][1]==88 && mat3[1][1]==88 && mat3[2][1]==88)|| // Teste para saber se marcou
- (mat3[0][2]==88 && mat3[1][2]==88 && mat3[2][2]==88)|| // Teste para saber se marcou
- (mat3[0][0]==88 && mat3[1][1]==88 && mat3[2][2]==88)|| // Teste para saber se marcou
- (mat3[0][2]==88 && mat3[1][1]==88 && mat3[2][0]==88)) // Teste para saber se marcou
- {
- velha.pont1++;
- }
- if ((mat3[0][0]==79 && mat3[0][1]==79 && mat3[0][2]==79)|| // Teste para saber se marcou
- (mat3[1][0]==79 && mat3[1][1]==79 && mat3[1][2]==79)|| // Teste para saber se marcou
- (mat3[2][0]==79 && mat3[2][1]==79 && mat3[2][2]==79)|| // Teste para saber se marcou
- (mat3[0][0]==79 && mat3[1][0]==79 && mat3[2][0]==79)|| // Teste para saber se marcou
- (mat3[0][1]==79 && mat3[1][1]==79 && mat3[2][1]==79)|| // Teste para saber se marcou
- (mat3[0][2]==79 && mat3[1][2]==79 && mat3[2][2]==79)|| // Teste para saber se marcou
- (mat3[0][0]==79 && mat3[1][1]==79 && mat3[2][2]==79)|| // Teste para saber se marcou
- (mat3[0][2]==79 && mat3[1][1]==79 && mat3[2][0]==79)) // Teste para saber se marcou
- {
- velha.pont2++;
- }
- break; // break do caso 3
- } // chave do switch
- if ((mat3[2][0]==88 && mat2[2][0]==88 && mat1[2][0]==88)|| // TESTE PARA SABER SE MARCOU PARTE 3D
- (mat3[2][1]==88 && mat2[2][1]==88 && mat1[2][1]==88)|| // TESTE PARA SABER SE MARCOU PARTE 3D
- (mat3[2][2]==88 && mat2[2][2]==88 && mat1[2][2]==88)|| // TESTE PARA SABER SE MARCOU PARTE 3D
- (mat3[0][1]==88 && mat2[0][1]==88 && mat1[0][1]==88)|| // TESTE PARA SABER SE MARCOU PARTE 3D
- (mat3[1][1]==88 && mat2[1][1]==88 && mat1[1][1]==88)|| // TESTE PARA SABER SE MARCOU PARTE 3D
- (mat3[1][2]==88 && mat2[1][2]==88 && mat1[1][2]==88)|| // TESTE PARA SABER SE MARCOU PARTE 3D
- (mat3[0][0]==88 && mat2[0][0]==88 && mat1[0][0]==88)|| // TESTE PARA SABER SE MARCOU PARTE 3D
- (mat3[0][1]==88 && mat2[0][1]==88 && mat1[0][1]==88)|| // TESTE PARA SABER SE MARCOU PARTE 3D
- (mat3[2][0]==88 && mat2[2][1]==88 && mat1[2][2]==88)|| // diagonal DA FATIA VERTICAL 3E
- (mat3[2][2]==88 && mat2[2][1]==88 && mat1[2][0]==88)|| // diagonal DA FATIA VERTICAL 3E
- (mat3[1][0]==88 && mat2[1][1]==88 && mat1[1][2]==88)|| // diagonal DA FATIA VERTICAL 3E
- (mat3[1][2]==88 && mat2[1][1]==88 && mat1[1][0]==88)|| // diagonal DA FATIA VERTICAL 3E
- (mat3[0][0]==88 && mat2[0][1]==88 && mat1[0][2]==88)|| // diagonal DA FATIA VERTICAL 3E
- (mat3[0][2]==88 && mat2[0][1]==88 && mat1[0][0]==88)|| // diagonal DA FATIA VERTICAL 3E
- (mat3[0][0]==88 && mat2[1][1]==88 && mat1[2][2]==88)|| // diagonal CUBO
- (mat3[0][2]==88 && mat2[1][1]==88 && mat1[2][0]==88)|| // diagonal CUBO
- (mat3[2][0]==88 && mat2[1][1]==88 && mat1[0][2]==88)|| // diagonal CUBO
- (mat3[2][2]==88 && mat2[1][1]==88 && mat1[0][0]==88)|| // diagonal CUBO
- (mat3[0][2]==88 && mat2[0][2]==88 && mat1[0][2]==88))
- {
- velha.pont1++;
- }
- if( (mat3[2][0]==79 && mat2[2][0]==79 && mat1[2][0]==79)|| // TESTE PARA SABER SE MARCOU PARTE 3D
- (mat3[2][1]==79 && mat2[2][1]==79 && mat1[2][1]==79)|| // TESTE PARA SABER SE MARCOU PARTE 3D
- (mat3[2][2]==79 && mat2[2][2]==79 && mat1[2][2]==79)|| // TESTE PARA SABER SE MARCOU PARTE 3D
- (mat3[0][1]==79 && mat2[0][1]==79 && mat1[0][1]==79)|| // TESTE PARA SABER SE MARCOU PARTE 3D
- (mat3[1][1]==79 && mat2[1][1]==79 && mat1[1][1]==79)|| // TESTE PARA SABER SE MARCOU PARTE 3D
- (mat3[1][2]==79 && mat2[1][2]==79 && mat1[1][2]==79)|| // TESTE PARA SABER SE MARCOU PARTE 3D
- (mat3[0][0]==79 && mat2[0][0]==79 && mat1[0][0]==79)|| // TESTE PARA SABER SE MARCOU PARTE 3D
- (mat3[0][1]==79 && mat2[0][1]==79 && mat1[0][1]==79)|| // TESTE PARA SABER SE MARCOU PARTE 3D
- (mat3[2][0]==79 && mat2[2][1]==79 && mat1[2][2]==79)|| // diagonal DA FATIA VERTICAL 3E
- (mat3[2][2]==79 && mat2[2][1]==79 && mat1[2][0]==79)|| // diagonal DA FATIA VERTICAL 3E
- (mat3[1][0]==79 && mat2[1][1]==79 && mat1[1][2]==79)|| // diagonal DA FATIA VERTICAL 3E
- (mat3[1][2]==79 && mat2[1][1]==79 && mat1[1][0]==79)|| // diagonal DA FATIA VERTICAL 3E
- (mat3[0][0]==79 && mat2[0][1]==79 && mat1[0][2]==79)|| // diagonal DA FATIA VERTICAL 3E
- (mat3[0][2]==79 && mat2[0][1]==79 && mat1[0][0]==79)|| // diagonal DA FATIA VERTICAL 3E
- (mat3[0][0]==79 && mat2[1][1]==79 && mat1[2][2]==79)|| // diagonal CUBO
- (mat3[0][2]==79 && mat2[1][1]==79 && mat1[2][0]==79)|| // diagonal CUBO
- (mat3[2][0]==79 && mat2[1][1]==79 && mat1[0][2]==79)|| // diagonal CUBO
- (mat3[2][2]==79 && mat2[1][1]==79 && mat1[0][0]==79)|| // diagonal CUBO
- (mat3[0][2]==79 && mat2[0][2]==79 && mat1[0][2]==79))
- {
- velha.pont2++;
- }
- andar3();
- andar2();
- andar1();
- cont1++; // PRINCIPAL CONTADOR, ONDE O JOGO RODA
- } // } do 'DO' PRINCIPAL
- while (cont1<29); // O JOGO RODA POR CAUSA DESSE WHILE
- if(cont1==27)
- printf("\n\nEMPATE\n\n");
- if(velha.pont1 > velha.pont2)
- printf("Jogador 1 venceu!\n\n");
- else
- printf("Jogador 2 venceu!\n\n");
- return continua();
- } // ultima chave
- void jogo() // funcao para rodar o jogo
- {
- char matn1[4][4];
- char matn2[4][4];
- char matn3[4][4];
- char matn4[4][4];
- int q;
- int i=0,j=0,k=0,m=0,aux1,cont1=2,aux2,contx=0,conty=0;
- int andarn4(){
- printf(" 4 andar\n");
- printf("\n %c| %c| %c| %c\n",matn4[0][0],matn4[0][1],matn4[0][2], matn4[0][3]); //Printar o tabuleiro
- printf("___________\n"); //Printar o tabuleiro
- printf(" %c| %c| %c| %c\n",matn4[1][0],matn4[1][1],matn4[1][2], matn4[1][3]); //Printar o tabuleiro
- printf("___________\n"); //Printar o tabuleiro
- printf(" %c| %c| %c| %c\n",matn4[2][0],matn4[2][1],matn4[2][2], matn4[2][3]); //Printar o tabuleiro
- printf("___________\n"); //Printar o tabuleiro
- printf(" %c| %c| %c| %c\n",matn4[3][0],matn4[3][1],matn4[3][2], matn4[3][3]); //Printar o tabuleiro
- printf(" \n");
- }
- int andarn3(){
- printf(" 3 andar\n");
- printf("\n %c| %c| %c| %c\n",matn3[0][0],matn3[0][1],matn3[0][2], matn3[0][3]); //Printar o tabuleiro
- printf("___________\n"); //Printar o tabuleiro
- printf(" %c| %c| %c| %c\n",matn3[1][0],matn3[1][1],matn3[1][2], matn3[1][3]); //Printar o tabuleiro
- printf("___________\n"); //Printar o tabuleiro
- printf(" %c| %c| %c| %c\n",matn3[2][0],matn3[2][1],matn3[2][2], matn3[2][3]); //Printar o tabuleiro
- printf("___________\n"); //Printar o tabuleiro
- printf(" %c| %c| %c| %c\n",matn3[3][0],matn3[3][1],matn3[3][2], matn3[3][3]); //Printar o tabuleiro
- printf(" \n");
- }
- int andarn2 (){
- printf(" 2 andar\n");
- printf("\n %c| %c| %c| %c\n",matn2[0][0],matn2[0][1],matn2[0][2], matn2[0][3]); //Printar o tabuleiro
- printf("___________\n"); //Printar o tabuleiro
- printf(" %c| %c| %c| %c\n",matn2[1][0],matn2[1][1],matn2[1][2], matn2[1][3]); //Printar o tabuleiro
- printf("___________\n"); //Printar o tabuleiro
- printf(" %c| %c| %c| %c\n",matn2[2][0],matn2[2][1],matn2[2][2], matn2[2][3]); //Printar o tabuleiro
- printf("___________\n"); //Printar o tabuleiro
- printf(" %c| %c| %c| %c\n",matn2[3][0],matn2[3][1],matn2[3][2], matn2[3][3]); //Printar o tabuleiro
- printf(" \n ");
- }
- int andarn1(){
- printf(" 1 andar\n");
- printf("\n %c| %c| %c| %c\n",matn1[0][0],matn1[0][1],matn1[0][2], matn1[0][3]); //Printar o tabuleiro
- printf("___________\n"); //Printar o tabuleiro
- printf(" %c| %c| %c| %c\n",matn1[1][0],matn1[1][1],matn1[1][2], matn1[1][3]); //Printar o tabuleiro
- printf("___________\n"); //Printar o tabuleiro
- printf(" %c| %c| %c| %c\n",matn1[2][0],matn1[2][1],matn1[2][2], matn1[2][3]); //Printar o tabuleiro
- printf("___________\n"); //Printar o tabuleiro
- printf(" %c| %c| %c| %c\n",matn1[3][0],matn1[3][1],matn1[3][2], matn1[3][3]); //Printar o tabuleiro
- printf(" \n \n \n ");
- printf(" \n\n");
- }
- for(i=0; i <=3; i++){ // preenchimento da matriz com ' '
- for(j=0; j <= 3 ; j++){ //preenche todas a posição com ' '
- matn1[i][j]=' ';
- matn2[i][j]=' ';
- matn3[i][j]=' ';
- matn4[i][j]=' ';
- } // SEGUNDO LACO FOR
- } // PRIMEIRO LACO FOR
- andarn4();
- andarn3();
- andarn2();
- andarn1();
- do
- {
- if (cont1 % 2 == 0) // SE FOR 0, q=88; SERÁ O JOGADOR 1, SE FOR q=79;, JOGADOR 2
- q=88;
- else
- q=79;
- do
- {
- printf("Escolha o andar: 1, 2, 3 ou 4:\n");
- scanf("%d", &aux1);
- if(aux1==1){ //Escolher o Andar
- if ((matn1[0][0]==88 || matn1[0][0]==79) && (matn1[0][1]==88 || matn1[0][1]==79) && //Verificar se o andar está preenchido
- (matn1[0][2]==88 || matn1[0][2]==79) && (matn1[0][3]==88 || matn1[0][3]==79) && //Verificar se o andar está preenchido
- (matn1[1][0]==88 || matn1[1][0]==79) && (matn1[1][1]==88 || matn1[1][1]==79) && //Verificar se o andar está preenchido
- (matn1[1][2]==88 || matn1[1][2]==79) && (matn1[1][3]==88 || matn1[1][3]==79) && //Verificar se o andar está preenchido
- (matn1[2][0]==88 || matn1[2][0]==79) && (matn1[2][1]==88 || matn1[2][1]==79) && //Verificar se o andar está preenchido
- (matn1[2][2]==88 || matn1[2][2]==79) && (matn1[2][3]==88 || matn1[2][3]==79) && //Verificar se o andar está preenchido
- (matn1[3][0]==88 || matn1[3][0]==79) && (matn1[3][1]==88 || matn1[3][1]==79) && //Verificar se o andar está preenchido
- (matn1[3][2]==88 || matn1[3][2]==79) && (matn1[3][3]==88 || matn1[3][3]==79)) //Verificar se o andar está preenchido
- {
- do{
- printf("ANDAR 1 PREENCHIDO!\nEscolha o andar disponivel: '2','3' ou '4':\n");
- scanf("%d", &aux1);} while((aux1 != 2) && (aux1 != 3) && (aux1 != 4));
- }
- }
- if(aux1==2){
- if ((matn2[0][0]==88 || matn2[0][0]==79) && (matn2[0][1]==88 || matn2[0][1]==79) && //Verificar se o andar está preenchido
- (matn2[0][2]==88 || matn2[0][2]==79) && (matn2[0][3]==88 || matn2[0][3]==79) &&
- (matn2[1][0]==88 || matn2[1][0]==79) && (matn2[1][1]==88 || matn2[1][1]==79) &&
- (matn2[1][2]==88 || matn2[1][2]==79) && (matn2[1][3]==88 || matn2[1][3]==79) &&
- (matn2[2][0]==88 || matn2[2][0]==79) && (matn2[2][1]==88 || matn2[2][1]==79) &&
- (matn2[2][2]==88 || matn2[2][2]==79) && (matn2[2][3]==88 || matn2[2][3]==79) &&
- (matn2[3][0]==88 || matn2[3][0]==79) && (matn2[3][1]==88 || matn2[3][1]==79) &&
- (matn2[3][2]==88 || matn2[3][2]==79) && (matn2[3][3]==88 || matn2[3][3]==79))
- {
- do{
- system("cls");
- printf("ANDAR 2 PREENCHIDO!\nEscolha o andar disponivel: '1','3' ou '4':\n");
- scanf("%d", &aux1);} while((aux1 != 1) && (aux1 != 3) && (aux1 != 4));
- }
- }
- if(aux1==3){
- if ((matn3[0][0]==88 || matn3[0][0]==79) && (matn3[0][1]==88 || matn3[0][1]==79) && //Verificar se o andar está preenchido
- (matn3[0][2]==88 || matn3[0][2]==79) && (matn3[0][3]==88 || matn3[0][3]==79) &&
- (matn3[1][0]==88 || matn3[1][0]==79) && (matn3[1][1]==88 || matn3[1][1]==79) &&
- (matn3[1][2]==88 || matn3[1][2]==79) && (matn3[1][3]==88 || matn3[1][3]==79) &&
- (matn3[2][0]==88 || matn3[2][0]==79) && (matn3[2][1]==88 || matn3[2][1]==79) &&
- (matn3[2][2]==88 || matn3[2][2]==79) && (matn3[2][3]==88 || matn3[2][3]==79) &&
- (matn3[3][0]==88 || matn3[3][0]==79) && (matn3[3][1]==88 || matn3[3][1]==79) &&
- (matn3[3][2]==88 || matn3[3][2]==79) && (matn3[3][3]==88 || matn3[3][3]==79))
- {
- do{
- system("cls");
- printf("ANDAR 3 PREENCHIDO!\nEscolha o andar disponivel: '1','2' ou '4':\n");
- scanf("%d", &aux1);} while((aux1 != 1) && (aux1 != 2) && (aux1 != 4));
- }
- }
- if(aux1==4){
- if ((matn4[0][0]==88 || matn4[0][0]==79) && (matn4[0][1]==88 || matn4[0][1]==79) && //Verificar se o andar está preenchido
- (matn4[0][2]==88 || matn4[0][2]==79) && (matn4[0][3]==88 || matn4[0][3]==79) &&
- (matn4[1][0]==88 || matn4[1][0]==79) && (matn4[1][1]==88 || matn4[1][1]==79) &&
- (matn4[1][2]==88 || matn4[1][2]==79) && (matn4[1][3]==88 || matn4[1][3]==79) &&
- (matn4[2][0]==88 || matn4[2][0]==79) && (matn4[2][1]==88 || matn4[2][1]==79) &&
- (matn4[2][2]==88 || matn4[2][2]==79) && (matn4[2][3]==88 || matn4[2][3]==79) &&
- (matn4[3][0]==88 || matn4[3][0]==79) && (matn4[3][1]==88 || matn4[3][1]==79) &&
- (matn4[3][2]==88 || matn4[3][2]==79) && (matn4[3][3]==88 || matn4[3][3]==79))
- {
- do{
- system("cls");
- printf("ANDAR 4 PREENCHIDO!\nEscolha o andar disponivel: '1','2' ou '3':\n");
- scanf("%d", &aux1);} while((aux1 != 1) && (aux1 != 2) && (aux1 != 3));
- }
- }
- } 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
- switch(aux1) // jogo
- {
- case 1 :
- do
- {
- printf("Em qual linha e coluna vc deseja marcar.\n");
- printf("Linha: "); // Preencher o tabuleiro
- scanf("%d",&i); // Preencher o tabuleiro
- printf("Coluna: "); // Preencher o tabuleiro
- scanf("%d",&j); // Preencher o tabuleiro
- system("cls");
- }
- 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
- matn1[i-1][j-1]= q ;
- // condicoes matriz n1
- if((matn1[0][0]== 88 && matn1[0][1]== 88 && matn1[0][2]== 88 && matn1[0][3]== 88 )|| // linha // Verificar se ganhou
- (matn1[1][0]== 88 && matn1[1][1]== 88 && matn1[1][2]== 88 && matn1[1][3]== 88 )|| // linha
- (matn1[2][0]== 88 && matn1[2][1]== 88 && matn1[2][2]== 88 && matn1[2][3]== 88 )|| // linha
- (matn1[3][0]== 88 && matn1[3][1]== 88 && matn1[3][2]== 88 && matn1[3][3]== 88 )|| // linha
- (matn1[0][0]== 88 && matn1[1][0]== 88 && matn1[2][0]== 88 && matn1[3][0]== 88 )|| // coluna
- (matn1[0][1]== 88 && matn1[1][1]== 88 && matn1[2][1]== 88 && matn1[3][1]== 88 )|| // coluna
- (matn1[0][2]== 88 && matn1[1][2]== 88 && matn1[2][2]== 88 && matn1[3][2]== 88 )|| // coluna
- (matn1[0][3]== 88 && matn1[1][3]== 88 && matn1[2][3]== 88 && matn1[3][3]== 88 )|| // coluna
- (matn1[0][0]== 88 && matn1[1][1]== 88 && matn1[2][2]== 88 && matn1[3][3]== 88 )|| // diagonal
- (matn1[3][0]== 88 && matn1[2][1]== 88 && matn1[1][2]== 88 && matn1[0][3]== 88 )) // diagonal
- {
- system("cls");
- printf("*********************************** \n");
- printf("* Parabens player 1 voce venceu!!!*\n");
- printf("***********************************\n\n");
- velha.pont1++;
- return continua();
- }
- if((matn1[0][0]== 79 && matn1[0][1]== 79 && matn1[0][2]== 79 && matn1[0][3]== 79 )|| // linha // Verificar se ganhou
- (matn1[1][0]== 79 && matn1[1][1]== 79 && matn1[1][2]== 79 && matn1[1][3]== 79 )|| // linha
- (matn1[2][0]== 79 && matn1[2][1]== 79 && matn1[2][2]== 79 && matn1[2][3]== 79 )|| // linha
- (matn1[3][0]== 79 && matn1[3][1]== 79 && matn1[3][2]== 79 && matn1[3][3]== 79 )|| // linha
- (matn1[0][0]== 79 && matn1[1][0]== 79 && matn1[2][0]== 79 && matn1[3][0]== 79 )|| // coluna
- (matn1[0][1]== 79 && matn1[1][1]== 79 && matn1[2][1]== 79 && matn1[3][1]== 79 )|| // coluna
- (matn1[0][2]== 79 && matn1[1][2]== 79 && matn1[2][2]== 79 && matn1[3][2]== 79 )|| // coluna
- (matn1[0][3]== 79 && matn1[1][3]== 79 && matn1[2][3]== 79 && matn1[3][3]== 79 )|| // coluna
- (matn1[0][0]== 79 && matn1[1][1]== 79 && matn1[2][2]== 79 && matn1[3][3]== 79 )|| // diagonal
- (matn1[3][0]== 79 && matn1[2][1]== 79 && matn1[1][2]== 79 && matn1[0][3]== 79 )) // diagonal
- {
- system("cls");
- printf("*********************************** \n");
- printf("* Parabens player 2 voce venceu!!!*\n");
- printf("***********************************\n\n");
- velha.pont2++;
- return continua();
- }
- if(cont1==68){
- printf("\n\nEMPATE\n\n");
- return continua();}
- break; // break do caso 1
- case 2 :
- do
- {
- printf("Em qual linha e coluna vc deseja marcar:\n");
- printf("Linha: "); // Preencher o tabuleiro
- scanf("%d",&i); // Preencher o tabuleiro
- printf("Coluna: "); // Preencher o tabuleiro
- scanf("%d",&j); // Preencher o tabuleiro
- system("cls");
- }
- 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
- matn2[i-1][j-1]= q ;
- if((matn2[0][0]== 88 && matn2[0][1]== 88 && matn2[0][2]== 88 && matn2[0][3]== 88 )|| // linha // Verificar se ganhou
- (matn2[1][0]== 88 && matn2[1][1]== 88 && matn2[1][2]== 88 && matn2[1][3]== 88 )|| // linha
- (matn2[2][0]== 88 && matn2[2][1]== 88 && matn2[2][2]== 88 && matn2[2][3]== 88 )|| // linha
- (matn2[3][0]== 88 && matn2[3][1]== 88 && matn2[3][2]== 88 && matn2[3][3]== 88 )|| // linha
- (matn2[0][0]== 88 && matn2[1][0]== 88 && matn2[2][0]== 88 && matn2[3][0]== 88 )|| // coluna
- (matn2[0][1]== 88 && matn2[1][1]== 88 && matn2[2][1]== 88 && matn2[3][1]== 88 )|| // coluna
- (matn2[0][2]== 88 && matn2[1][2]== 88 && matn2[2][2]== 88 && matn2[3][2]== 88 )|| // coluna
- (matn2[0][3]== 88 && matn2[1][3]== 88 && matn2[2][3]== 88 && matn2[3][3]== 88 )|| // coluna
- (matn2[0][0]== 88 && matn2[1][1]== 88 && matn2[2][2]== 88 && matn2[3][3]== 88 )|| // diagonal
- (matn2[3][0]== 88 && matn2[2][1]== 88 && matn2[1][2]== 88 && matn2[0][3]== 88 )) // diagonal
- {
- system("cls");
- printf("*********************************** \n");
- printf("* Parabens player 1 voce venceu!!!*\n");
- printf("***********************************\n\n");
- velha.pont1++;
- return continua();
- }
- if((matn2[0][0]== 79 && matn2[0][1]== 79 && matn2[0][2]== 79 && matn2[0][3]== 79 )|| // linha // Verificar se ganhou
- (matn2[1][0]== 79 && matn2[1][1]== 79 && matn2[1][2]== 79 && matn2[1][3]== 79 )|| // linha
- (matn2[2][0]== 79 && matn2[2][1]== 79 && matn2[2][2]== 79 && matn2[2][3]== 79 )|| // linha
- (matn2[3][0]== 79 && matn2[3][1]== 79 && matn2[3][2]== 79 && matn2[3][3]== 79 )|| // linha
- (matn2[0][0]== 79 && matn2[1][0]== 79 && matn2[2][0]== 79 && matn2[3][0]== 79 )|| // coluna
- (matn2[0][1]== 79 && matn2[1][1]== 79 && matn2[2][1]== 79 && matn2[3][1]== 79 )|| // coluna
- (matn2[0][2]== 79 && matn2[1][2]== 79 && matn2[2][2]== 79 && matn2[3][2]== 79 )|| // coluna
- (matn2[0][3]== 79 && matn2[1][3]== 79 && matn2[2][3]== 79 && matn2[3][3]== 79 )|| // coluna
- (matn2[0][0]== 79 && matn2[1][1]== 79 && matn2[2][2]== 79 && matn2[3][3]== 79 )|| // diagonal
- (matn2[3][0]== 79 && matn2[2][1]== 79 && matn2[1][2]== 79 && matn2[0][3]== 79 )) // diagonal
- {
- system("cls");
- printf("*********************************** \n");
- printf("* Parabens player 2 voce venceu!!!*\n");
- printf("***********************************\n\n");
- velha.pont2++;
- return continua();
- }
- if(cont1==68){
- printf("\n\nEMPATE\n\n");
- return continua();}
- break;// break do caso 2
- case 3 :
- do
- {
- printf("Em qual linha e coluna vc deseja marcar.\n");
- printf("Linha: "); // Preencher o tabuleiro
- scanf("%d",&i); // Preencher o tabuleiro
- printf("Coluna: "); // Preencher o tabuleiro
- scanf("%d",&j); // Preencher o tabuleiro
- system("cls");
- }
- 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
- matn3[i-1][j-1]= q ;
- // condicoes matriz n3
- if((matn3[0][0]== 88 && matn3[0][1]== 88 && matn3[0][2]== 88 && matn3[0][3]== 88 )|| // linha // Verificar se ganhou
- (matn3[1][0]== 88 && matn3[1][1]== 88 && matn3[1][2]== 88 && matn3[1][3]== 88 )|| // linha
- (matn3[2][0]== 88 && matn3[2][1]== 88 && matn3[2][2]== 88 && matn3[2][3]== 88 )|| // linha
- (matn3[3][0]== 88 && matn3[3][1]== 88 && matn3[3][2]== 88 && matn3[3][3]== 88 )|| // linha
- (matn3[0][0]== 88 && matn3[1][0]== 88 && matn3[2][0]== 88 && matn3[3][0]== 88 )|| // coluna
- (matn3[0][1]== 88 && matn3[1][1]== 88 && matn3[2][1]== 88 && matn3[3][1]== 88 )|| // coluna
- (matn3[0][2]== 88 && matn3[1][2]== 88 && matn3[2][2]== 88 && matn3[3][2]== 88 )|| // coluna
- (matn3[0][3]== 88 && matn3[1][3]== 88 && matn3[2][3]== 88 && matn3[3][3]== 88 )|| // coluna
- (matn3[0][0]== 88 && matn3[1][1]== 88 && matn3[2][2]== 88 && matn3[3][3]== 88 )|| // diagonal
- (matn3[3][0]== 88 && matn3[2][1]== 88 && matn3[1][2]== 88 && matn3[0][3]== 88 )) // diagonal
- {
- system("cls");
- printf("\t\t\t\t*********************************** \n");
- printf("\t\t\t\t* Parabens player 1 voce venceu!!!*\n");
- printf("\t\t\t\t***********************************\n\n");
- velha.pont1++;
- return continua();
- }
- if ((matn3[0][0]== 79 && matn3[0][1]== 79 && matn3[0][2]== 79 && matn3[0][3]== 79 )|| // linha
- (matn3[1][0]== 79 && matn3[1][1]== 79 && matn3[1][2]== 79 && matn3[1][3]== 79 )|| // linha
- (matn3[2][0]== 79 && matn3[2][1]== 79 && matn3[2][2]== 79 && matn3[2][3]== 79 )|| // linha
- (matn3[3][0]== 79 && matn3[3][1]== 79 && matn3[3][2]== 79 && matn3[3][3]== 79 )|| // linha
- (matn3[0][0]== 79 && matn3[1][0]== 79 && matn3[2][0]== 79 && matn3[3][0]== 79 )|| // coluna
- (matn3[0][1]== 79 && matn3[1][1]== 79 && matn3[2][1]== 79 && matn3[3][1]== 79 )|| // coluna
- (matn3[0][2]== 79 && matn3[1][2]== 79 && matn3[2][2]== 79 && matn3[3][2]== 79 )|| // coluna
- (matn3[0][3]== 79 && matn3[1][3]== 79 && matn3[2][3]== 79 && matn3[3][3]== 79 )|| // coluna
- (matn3[0][0]== 79 && matn3[1][1]== 79 && matn3[2][2]== 79 && matn3[3][3]== 79 )|| // diagonal
- (matn3[3][0]== 79 && matn3[2][1]== 79 && matn3[1][2]== 79 && matn3[0][3]== 79 )) // diagonal
- {
- system("cls");
- printf("\t\t\t\t*********************************** \n");
- printf("\t\t\t\t* Parabens player 2 voce venceu!!!*\n");
- printf("\t\t\t\t***********************************\n\n");
- velha.pont2++;
- return continua();
- }
- if(cont1==68){
- printf("\n\nEMPATE\n\n");
- return continua();}
- break; // break do caso 3
- case 4 :
- do
- {
- printf("Em qual linha e coluna vc deseja marcar.\n");
- printf("Linha: "); // Preencher o tabuleiro
- scanf("%d",&i); // Preencher o tabuleiro
- printf("Coluna: "); // Preencher o tabuleiro
- scanf("%d",&j); // Preencher o tabuleiro
- system("cls");
- }
- 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
- matn4[i-1][j-1]= q ;
- if((matn4[0][0]== 88 && matn4[0][1]== 88 && matn4[0][2]== 88 && matn4[0][3]== 88 )|| // linha
- (matn4[1][0]== 88 && matn4[1][1]== 88 && matn4[1][2]== 88 && matn4[1][3]== 88 )|| // linha
- (matn4[2][0]== 88 && matn4[2][1]== 88 && matn4[2][2]== 88 && matn4[2][3]== 88 )|| // linha
- (matn4[3][0]== 88 && matn4[3][1]== 88 && matn4[3][2]== 88 && matn4[3][3]== 88 )|| // linha
- (matn4[0][0]== 88 && matn4[1][0]== 88 && matn4[2][0]== 88 && matn4[3][0]== 88 )|| // coluna
- (matn4[0][1]== 88 && matn4[1][1]== 88 && matn4[2][1]== 88 && matn4[3][1]== 88 )|| // coluna
- (matn4[0][2]== 88 && matn4[1][2]== 88 && matn4[2][2]== 88 && matn4[3][2]== 88 )|| // coluna
- (matn4[0][3]== 88 && matn4[1][3]== 88 && matn4[2][3]== 88 && matn4[3][3]== 88 )|| // coluna
- (matn4[0][0]== 88 && matn4[1][1]== 88 && matn4[2][2]== 88 && matn4[3][3]== 88 )|| // diagonal
- (matn4[3][0]== 88 && matn4[2][1]== 88 && matn4[1][2]== 88 && matn4[0][3]== 88 )) // diagonal
- {
- system("cls");
- printf("*********************************** \n");
- printf("* Parabens player 1 voce venceu!!!*\n");
- printf("***********************************\n\n");
- velha.pont1++;
- return continua();
- }
- if ((matn4[0][0]== 79 && matn4[0][1]== 79 && matn4[0][2]== 79 && matn4[0][3]== 79 )|| // linha
- (matn4[1][0]== 79 && matn4[1][1]== 79 && matn4[1][2]== 79 && matn4[1][3]== 79 )|| // linha
- (matn4[2][0]== 79 && matn4[2][1]== 79 && matn4[2][2]== 79 && matn4[2][3]== 79 )|| // linha
- (matn4[3][0]== 79 && matn4[3][1]== 79 && matn4[3][2]== 79 && matn4[3][3]== 79 )|| // linha
- (matn4[0][0]== 79 && matn4[1][0]== 79 && matn4[2][0]== 79 && matn4[3][0]== 79 )|| // coluna
- (matn4[0][1]== 79 && matn4[1][1]== 79 && matn4[2][1]== 79 && matn4[3][1]== 79 )|| // coluna
- (matn4[0][2]== 79 && matn4[1][2]== 79 && matn4[2][2]== 79 && matn4[3][2]== 79 )|| // coluna
- (matn4[0][3]== 79 && matn4[1][3]== 79 && matn4[2][3]== 79 && matn4[3][3]== 79 )|| // coluna
- (matn4[0][0]== 79 && matn4[1][1]== 79 && matn4[2][2]== 79 && matn4[3][3]== 79 )|| // diagonal
- (matn4[3][0]== 79 && matn4[2][1]== 79 && matn4[1][2]== 79 && matn4[0][3]== 79 )) // diagonal
- {
- system("cls");
- printf("*********************************** \n");
- printf("* Parabens player 1 voce venceu!!!*\n");
- printf("***********************************\n\n");
- velha.pont2++;
- return continua();
- }
- if(cont1==68){
- printf("\n\nEMPATE\n\n");
- return continua();}
- break;// break do caso 5
- } //chave do switch
- if((matn4[3][0]== 88 && matn3[3][0]== 88 && matn4[3][0]== 88 && matn1[3][0]== 88 )|| //colunaface // Teste para saber se ganhou
- (matn4[3][1]== 88 && matn3[3][1]== 88 && matn1[3][1]== 88 && matn1[3][1]== 88 )|| //colunaface
- (matn4[3][2]== 88 && matn3[3][2]== 88 && matn2[3][2]== 88 && matn1[3][2]== 88 )|| //colunaface
- (matn4[3][3]== 88 && matn3[3][3]== 88 && matn2[3][3]== 88 && matn1[3][3]== 88 )|| //colunaface
- (matn4[2][0]== 88 && matn3[2][0]== 88 && matn2[2][0]== 88 && matn1[2][0]== 88 )|| //colunaface
- (matn4[2][1]== 88 && matn3[2][1]== 88 && matn2[2][1]== 88 && matn1[2][1]== 88 )|| //colunaface
- (matn4[2][2]== 88 && matn3[2][2]== 88 && matn2[2][2]== 88 && matn1[2][2]== 88 )|| //colunaface
- (matn4[2][3]== 88 && matn3[2][3]== 88 && matn2[2][3]== 88 && matn1[2][3]== 88 )|| //colunaface
- (matn4[1][0]== 88 && matn3[1][0]== 88 && matn2[1][0]== 88 && matn1[1][0]== 88 )|| //colunaface
- (matn4[1][1]== 88 && matn3[1][1]== 88 && matn2[1][1]== 88 && matn1[1][1]== 88 )|| //colunaface
- (matn4[1][2]== 88 && matn3[1][2]== 88 && matn2[1][2]== 88 && matn1[1][2]== 88 )|| //colunaface
- (matn4[1][3]== 88 && matn3[1][3]== 88 && matn2[1][3]== 88 && matn1[1][3]== 88 )|| //colunaface
- (matn4[0][0]== 88 && matn3[0][0]== 88 && matn2[0][0]== 88 && matn1[0][0]== 88 )|| //colunaface
- (matn4[0][1]== 88 && matn3[0][1]== 88 && matn2[0][1]== 88 && matn1[0][1]== 88 )|| //colunaface
- (matn4[0][2]== 88 && matn3[0][2]== 88 && matn2[0][2]== 88 && matn1[0][2]== 88 )|| //colunaface
- (matn4[0][3]== 88 && matn3[0][3]== 88 && matn2[0][3]== 88 && matn1[0][3]== 88 )|| //colunaface
- (matn4[0][2]== 88 && matn3[0][2]== 88 && matn2[0][2]== 88 && matn1[0][2]== 88 )|| //colunaface
- (matn4[3][0]== 88 && matn3[3][1]== 88 && matn2[3][2]== 88 && matn1[3][3]== 88 )|| // \ diagonalface1
- (matn4[3][3]== 88 && matn3[3][2]== 88 && matn2[3][1]== 88 && matn1[3][0]== 88 )|| // / giagonalface1
- (matn4[2][0]== 88 && matn3[2][1]== 88 && matn2[2][2]== 88 && matn1[2][3]== 88 )|| // \ diagonalface2
- (matn4[2][3]== 88 && matn3[2][2]== 88 && matn2[2][1]== 88 && matn1[2][0]== 88 )|| // / giagonalface2
- (matn4[1][0]== 88 && matn3[1][1]== 88 && matn2[1][2]== 88 && matn1[1][3]== 88 )|| // \ diagonalface3
- (matn4[1][3]== 88 && matn3[1][2]== 88 && matn2[1][1]== 88 && matn1[1][0]== 88 )|| // \ diagonalface3
- (matn4[0][0]== 88 && matn3[0][1]== 88 && matn2[0][2]== 88 && matn1[0][3]== 88 )|| // \ diagonalface4
- (matn4[0][3]== 88 && matn3[0][2]== 88 && matn2[0][1]== 88 && matn1[0][0]== 88 )|| // \ diagonalface4
- (matn4[3][0]== 88 && matn3[2][1]== 88 && matn2[1][2]== 88 && matn1[0][3]== 88 )|| //diagonalcubo
- (matn4[3][3]== 88 && matn3[2][2]== 88 && matn2[1][1]== 88 && matn1[0][0]== 88 )|| //diagonalcubo
- (matn4[0][0]== 88 && matn3[1][1]== 88 && matn2[2][2]== 88 && matn1[3][3]== 88 )|| //diagonalcubo
- (matn4[0][3]== 88 && matn3[1][2]== 88 && matn2[2][1]== 88 && matn1[3][0]== 88 )) //diagonalcubo
- {
- system("cls");
- printf("*********************************** \n");
- printf("* Parabens player 1 voce venceu!!!*\n");
- printf("***********************************\n\n");
- velha.pont1++;
- return continua();
- }
- if((matn4[3][0]== 79 && matn3[3][0]== 79 && matn4[3][0]== 79 && matn1[3][0]== 79 )|| //colunaface // Teste para saber se ganhou
- (matn4[3][1]== 79 && matn3[3][1]== 79 && matn1[3][1]== 79 && matn1[3][1]== 79 )|| //colunaface
- (matn4[3][2]== 79 && matn3[3][2]== 79 && matn2[3][2]== 79 && matn1[3][2]== 79 )|| //colunaface
- (matn4[3][3]== 79 && matn3[3][3]== 79 && matn2[3][3]== 79 && matn1[3][3]== 79 )|| //colunaface
- (matn4[2][0]== 79 && matn3[2][0]== 79 && matn2[2][0]== 79 && matn1[2][0]== 79 )|| //colunaface
- (matn4[2][1]== 79 && matn3[2][1]== 79 && matn2[2][1]== 79 && matn1[2][1]== 79 )|| //colunaface
- (matn4[2][2]== 79 && matn3[2][2]== 79 && matn2[2][2]== 79 && matn1[2][2]== 79 )|| //colunaface
- (matn4[2][3]== 79 && matn3[2][3]== 79 && matn2[2][3]== 79 && matn1[2][3]== 79 )|| //colunaface
- (matn4[1][0]== 79 && matn3[1][0]== 79 && matn2[1][0]== 79 && matn1[1][0]== 79 )|| //colunaface
- (matn4[1][1]== 79 && matn3[1][1]== 79 && matn2[1][1]== 79 && matn1[1][1]== 79 )|| //colunaface
- (matn4[1][2]== 79 && matn3[1][2]== 79 && matn2[1][2]== 79 && matn1[1][2]== 79 )|| //colunaface
- (matn4[1][3]== 79 && matn3[1][3]== 79 && matn2[1][3]== 79 && matn1[1][3]== 79 )|| //colunaface
- (matn4[0][0]== 79 && matn3[0][0]== 79 && matn2[0][0]== 79 && matn1[0][0]== 79 )|| //colunaface
- (matn4[0][1]== 79 && matn3[0][1]== 79 && matn2[0][1]== 79 && matn1[0][1]== 79 )|| //colunaface
- (matn4[0][2]== 79 && matn3[0][2]== 79 && matn2[0][2]== 79 && matn1[0][2]== 79 )|| //colunaface
- (matn4[0][3]== 79 && matn3[0][3]== 79 && matn2[0][3]== 79 && matn1[0][3]== 79 )|| //colunaface
- (matn4[0][2]== 79 && matn3[0][2]== 79 && matn2[0][2]== 79 && matn1[0][2]== 79 )|| //colunaface
- (matn4[3][0]== 79 && matn3[3][1]== 79 && matn2[3][2]== 79 && matn1[3][3]== 79 )|| // \ diagonalface1
- (matn4[3][3]== 79 && matn3[3][2]== 79 && matn2[3][1]== 79 && matn1[3][0]== 79 )|| // / giagonalface1
- (matn4[2][0]== 79 && matn3[2][1]== 79 && matn2[2][2]== 79 && matn1[2][3]== 79 )|| // \ diagonalface2
- (matn4[2][3]== 79 && matn3[2][2]== 79 && matn2[2][1]== 79 && matn1[2][0]== 79 )|| // / giagonalface2
- (matn4[1][0]== 79 && matn3[1][1]== 79 && matn2[1][2]== 79 && matn1[1][3]== 79 )|| // \ diagonalface3
- (matn4[1][3]== 79 && matn3[1][2]== 79 && matn2[1][1]== 79 && matn1[1][0]== 79 )|| // \ diagonalface3
- (matn4[0][0]== 79 && matn3[0][1]== 79 && matn2[0][2]== 79 && matn1[0][3]== 79 )|| // \ diagonalface4
- (matn4[0][3]== 79 && matn3[0][2]== 79 && matn2[0][1]== 79 && matn1[0][0]== 79 )|| // \ diagonalface4
- (matn4[3][0]== 79 && matn3[2][1]== 79 && matn2[1][2]== 79 && matn1[0][3]== 79 )|| //diagonalcubo
- (matn4[3][3]== 79 && matn3[2][2]== 79 && matn2[1][1]== 79 && matn1[0][0]== 79 )|| //diagonalcubo
- (matn4[0][0]== 79 && matn3[1][1]== 79 && matn2[2][2]== 79 && matn1[3][3]== 79 )|| //diagonalcubo
- (matn4[0][3]== 79 && matn3[1][2]== 79 && matn2[2][1]== 79 && matn1[3][0]== 79 )) //diagonalcubo
- {
- system("cls");
- printf("*********************************** \n");
- printf("* Parabens player 2 voce venceu!!!*\n");
- printf("***********************************\n\n");
- velha.pont2++;
- return continua();
- }
- if(cont1==68){
- printf("\n\nEMPATE\n\n");
- return continua();}
- andarn4();
- andarn3();
- andarn2();
- andarn1();
- cont1++; // contador para o primeiro if else
- }
- while (cont1<68);
- if(velha.pont1 > velha.pont2)
- printf("Jogador 1 venceu!\n\n");
- else
- printf("Jogador 2 venceu!\n\n");
- return continua();
- }
- void jogo1 (){
- char matn1[4][4];
- char matn2[4][4];
- char matn3[4][4];
- char matn4[4][4];
- int q;
- int i=0,j=0,k=0,m=0,aux1,cont1=4,aux2,contx=0,conty=0;
- int andarn4(){
- printf(" 4 andar\n");
- printf("\n %c| %c| %c| %c\n",matn4[0][0],matn4[0][1],matn4[0][2], matn4[0][3]); //Printar o tabuleiro
- printf("___________\n"); //Printar o tabuleiro
- printf(" %c| %c| %c| %c\n",matn4[1][0],matn4[1][1],matn4[1][2], matn4[1][3]); //Printar o tabuleiro
- printf("___________\n"); //Printar o tabuleiro
- printf(" %c| %c| %c| %c\n",matn4[2][0],matn4[2][1],matn4[2][2], matn4[2][3]); //Printar o tabuleiro
- printf("___________\n"); //Printar o tabuleiro
- printf(" %c| %c| %c| %c\n",matn4[3][0],matn4[3][1],matn4[3][2], matn4[3][3]); //Printar o tabuleiro
- printf(" \n");
- }
- int andarn3(){
- printf(" 3 andar\n");
- printf("\n %c| %c| %c| %c\n",matn3[0][0],matn3[0][1],matn3[0][2], matn3[0][3]); //Printar o tabuleiro
- printf("___________\n"); //Printar o tabuleiro
- printf(" %c| %c| %c| %c\n",matn3[1][0],matn3[1][1],matn3[1][2], matn3[1][3]); //Printar o tabuleiro
- printf("___________\n"); //Printar o tabuleiro
- printf(" %c| %c| %c| %c\n",matn3[2][0],matn3[2][1],matn3[2][2], matn3[2][3]); //Printar o tabuleiro
- printf("___________\n"); //Printar o tabuleiro
- printf(" %c| %c| %c| %c\n",matn3[3][0],matn3[3][1],matn3[3][2], matn3[3][3]); //Printar o tabuleiro
- printf(" \n");
- }
- int andarn2 (){
- printf(" 2 andar\n");
- printf("\n %c| %c| %c| %c\n",matn2[0][0],matn2[0][1],matn2[0][2], matn2[0][3]); //Printar o tabuleiro
- printf("___________\n"); //Printar o tabuleiro
- printf(" %c| %c| %c| %c\n",matn2[1][0],matn2[1][1],matn2[1][2], matn2[1][3]); //Printar o tabuleiro
- printf("___________\n"); //Printar o tabuleiro
- printf(" %c| %c| %c| %c\n",matn2[2][0],matn2[2][1],matn2[2][2], matn2[2][3]); //Printar o tabuleiro
- printf("___________\n"); //Printar o tabuleiro
- printf(" %c| %c| %c| %c\n",matn2[3][0],matn2[3][1],matn2[3][2], matn2[3][3]); //Printar o tabuleiro
- printf(" \n ");
- }
- int andarn1(){
- printf(" 1 andar\n");
- printf("\n %c| %c| %c| %c\n",matn1[0][0],matn1[0][1],matn1[0][2], matn1[0][3]); //Printar o tabuleiro
- printf("___________\n"); //Printar o tabuleiro
- printf(" %c| %c| %c| %c\n",matn1[1][0],matn1[1][1],matn1[1][2], matn1[1][3]); //Printar o tabuleiro
- printf("___________\n"); //Printar o tabuleiro
- printf(" %c| %c| %c| %c\n",matn1[2][0],matn1[2][1],matn1[2][2], matn1[2][3]); //Printar o tabuleiro
- printf("___________\n"); //Printar o tabuleiro
- printf(" %c| %c| %c| %c\n",matn1[3][0],matn1[3][1],matn1[3][2], matn1[3][3]); //Printar o tabuleiro
- printf(" \n \n \n ");
- printf(" \n\n");
- }
- for(i=0; i <=3; i++) // preenchimento da matriz com ' '
- {
- for(j=0; j <= 3 ; j++) //preenche todas a posição com ' ' //
- {
- matn1[i][j]=' ';
- matn2[i][j]=' ';
- matn3[i][j]=' ';
- matn4[i][j]=' ';
- } // SEGUNDO LACO FOR
- } // PRIMEIRO LACO FOR
- andarn4();
- andarn3();
- andarn2();
- andarn1();
- do
- {
- if (cont1 % 3 == 1) // SE FOR 0, q=88; SERÁ O JOGADOR 1, SE FOR q=79;, JOGADOR 2
- q=88;
- if (cont1 % 3 == 2) // SE FOR 0, q=88; SERÁ O JOGADOR 1, SE FOR q=79;, JOGADOR 2
- q=79;
- if (cont1 % 3 == 0) // SE FOR 0, q=88; SERÁ O JOGADOR 1, SE FOR q=79;, JOGADOR 2
- q=30;
- do
- {
- printf("Escolha o andar: 1, 2, 3 ou 4:\n");
- scanf("%d", &aux1);
- if(aux1==1){ //Escolher o Andar
- 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
- (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
- (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
- (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
- (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
- (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
- (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
- (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
- {
- do{
- printf("ANDAR 1 PREENCHIDO!\nEscolha o andar disponivel: '2','3' ou '4':\n");
- scanf("%d", &aux1);} while((aux1 != 2) && (aux1 != 3) && (aux1 != 4));
- }
- }
- if(aux1==2){
- 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
- (matn2[0][2]==88 || matn2[0][2]==79 || matn2[0][2]==30) && (matn2[0][3]==88 || matn2[0][3]==79 || matn2[0][3]==30) &&
- (matn2[1][0]==88 || matn2[1][0]==79 || matn2[1][0]==30) && (matn2[1][1]==88 || matn2[1][1]==79 || matn2[1][1]==30) &&
- (matn2[1][2]==88 || matn2[1][2]==79 || matn2[1][2]==30) && (matn2[1][3]==88 || matn2[1][3]==79 || matn2[1][3]==30) &&
- (matn2[2][0]==88 || matn2[2][0]==79 || matn2[2][0]==30) && (matn2[2][1]==88 || matn2[2][1]==79 || matn2[2][1]==30) &&
- (matn2[2][2]==88 || matn2[2][2]==79 || matn2[2][2]==30) && (matn2[2][3]==88 || matn2[2][3]==79 || matn2[2][3]==30) &&
- (matn2[3][0]==88 || matn2[3][0]==79 || matn2[3][0]==30) && (matn2[3][1]==88 || matn2[3][1]==79 || matn2[3][1]==30) &&
- (matn2[3][2]==88 || matn2[3][2]==79 || matn2[3][2]==30) && (matn2[3][3]==88 || matn2[3][3]==79 || matn2[3][3]==30))
- {
- do{
- printf("ANDAR 2 PREENCHIDO!\nEscolha o andar disponivel: '1','3' ou '4':\n");
- scanf("%d", &aux1);} while((aux1 != 1) && (aux1 != 3) && (aux1 != 4));
- }
- }
- if(aux1==3){
- 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
- (matn3[0][2]==88 || matn3[0][2]==79 || matn3[0][2]==30) && (matn3[0][3]==88 || matn3[0][3]==79 || matn3[0][3]==30) &&
- (matn3[1][0]==88 || matn3[1][0]==79 || matn3[1][0]==30) && (matn3[1][1]==88 || matn3[1][1]==79 || matn3[1][1]==30) &&
- (matn3[1][2]==88 || matn3[1][2]==79 || matn3[1][2]==30) && (matn3[1][3]==88 || matn3[1][3]==79 || matn3[1][3]==30) &&
- (matn3[2][0]==88 || matn3[2][0]==79 || matn3[2][0]==30) && (matn3[2][1]==88 || matn3[2][1]==79 || matn3[2][1]==30) &&
- (matn3[2][2]==88 || matn3[2][2]==79 || matn3[2][2]==30) && (matn3[2][3]==88 || matn3[2][3]==79 || matn3[2][3]==30) &&
- (matn3[3][0]==88 || matn3[3][0]==79 || matn3[3][0]==30) && (matn3[3][1]==88 || matn3[3][1]==79 || matn3[3][1]==30) &&
- (matn3[3][2]==88 || matn3[3][2]==79 || matn3[3][2]==30) && (matn3[3][3]==88 || matn3[3][3]==79 || matn3[3][3]==30))
- {
- do{
- printf("ANDAR 3 PREENCHIDO!\nEscolha o andar disponivel: '1','2' ou '4':\n");
- scanf("%d", &aux1);} while((aux1 != 1) && (aux1 != 2) && (aux1 != 4));
- }
- }
- if(aux1==4){
- 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
- (matn4[0][2]==88 || matn4[0][2]==79 || matn4[0][2]==30) && (matn4[0][3]==88 || matn4[0][3]==79 || matn4[0][3]==30) &&
- (matn4[1][0]==88 || matn4[1][0]==79 || matn4[1][0]==30) && (matn4[1][1]==88 || matn4[1][1]==79 || matn4[1][1]==30) &&
- (matn4[1][2]==88 || matn4[1][2]==79 || matn4[1][2]==30) && (matn4[1][3]==88 || matn4[1][3]==79 || matn4[1][3]==30) &&
- (matn4[2][0]==88 || matn4[2][0]==79 || matn4[2][0]==30) && (matn4[2][1]==88 || matn4[2][1]==79 || matn4[2][1]==30) &&
- (matn4[2][2]==88 || matn4[2][2]==79 || matn4[2][2]==30) && (matn4[2][3]==88 || matn4[2][3]==79 || matn4[2][3]==30) &&
- (matn4[3][0]==88 || matn4[3][0]==79 || matn4[3][0]==30) && (matn4[3][1]==88 || matn4[3][1]==79 || matn4[3][1]==30) &&
- (matn4[3][2]==88 || matn4[3][2]==79 || matn4[3][2]==30) && (matn4[3][3]==88 || matn4[3][3]==79 || matn4[3][3]==30))
- {
- do{
- printf("ANDAR 4 PREENCHIDO!\nEscolha o andar disponivel: '1','2' ou '3':\n");
- scanf("%d", &aux1);} while((aux1 != 1) && (aux1 != 2) && (aux1 != 3));
- }
- }
- } 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
- switch(aux1) // jogo
- {
- case 1 :
- do
- {
- printf("Em qual linha e coluna vc deseja marcar.\n");
- printf("Linha: "); // Preencher o tabuleiro
- scanf("%d",&i); // Preencher o tabuleiro
- printf("Coluna: "); // Preencher o tabuleiro
- scanf("%d",&j); // Preencher o tabuleiro
- system("cls");
- }
- 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
- matn1[i-1][j-1]= q ;
- // condicoes matriz n1
- if((matn1[0][0]== 88 && matn1[0][1]== 88 && matn1[0][2]== 88 && matn1[0][3]== 88 )|| // linha // Verificar se ganhou
- (matn1[1][0]== 88 && matn1[1][1]== 88 && matn1[1][2]== 88 && matn1[1][3]== 88 )|| // linha
- (matn1[2][0]== 88 && matn1[2][1]== 88 && matn1[2][2]== 88 && matn1[2][3]== 88 )|| // linha
- (matn1[3][0]== 88 && matn1[3][1]== 88 && matn1[3][2]== 88 && matn1[3][3]== 88 )|| // linha
- (matn1[0][0]== 88 && matn1[1][0]== 88 && matn1[2][0]== 88 && matn1[3][0]== 88 )|| // coluna
- (matn1[0][1]== 88 && matn1[1][1]== 88 && matn1[2][1]== 88 && matn1[3][1]== 88 )|| // coluna
- (matn1[0][2]== 88 && matn1[1][2]== 88 && matn1[2][2]== 88 && matn1[3][2]== 88 )|| // coluna
- (matn1[0][3]== 88 && matn1[1][3]== 88 && matn1[2][3]== 88 && matn1[3][3]== 88 )|| // coluna
- (matn1[0][0]== 88 && matn1[1][1]== 88 && matn1[2][2]== 88 && matn1[3][3]== 88 )|| // diagonal
- (matn1[3][0]== 88 && matn1[2][1]== 88 && matn1[1][2]== 88 && matn1[0][3]== 88 )) // diagonal
- {
- printf("\t\t\t\t*********************************** \n");
- printf("\t\t\t\t* Parabens player 1 voce venceu!!!*\n");
- printf("\t\t\t\t***********************************\n\n");
- velha.pont1++;
- system("pause");
- return continua();
- }
- if((matn1[0][0]== 79 && matn1[0][1]== 79 && matn1[0][2]== 79 && matn1[0][3]== 79 )|| // linha // Verificar se ganhou
- (matn1[1][0]== 79 && matn1[1][1]== 79 && matn1[1][2]== 79 && matn1[1][3]== 79 )|| // linha
- (matn1[2][0]== 79 && matn1[2][1]== 79 && matn1[2][2]== 79 && matn1[2][3]== 79 )|| // linha
- (matn1[3][0]== 79 && matn1[3][1]== 79 && matn1[3][2]== 79 && matn1[3][3]== 79 )|| // linha
- (matn1[0][0]== 79 && matn1[1][0]== 79 && matn1[2][0]== 79 && matn1[3][0]== 79 )|| // coluna
- (matn1[0][1]== 79 && matn1[1][1]== 79 && matn1[2][1]== 79 && matn1[3][1]== 79 )|| // coluna
- (matn1[0][2]== 79 && matn1[1][2]== 79 && matn1[2][2]== 79 && matn1[3][2]== 79 )|| // coluna
- (matn1[0][3]== 79 && matn1[1][3]== 79 && matn1[2][3]== 79 && matn1[3][3]== 79 )|| // coluna
- (matn1[0][0]== 79 && matn1[1][1]== 79 && matn1[2][2]== 79 && matn1[3][3]== 79 )|| // diagonal
- (matn1[3][0]== 79 && matn1[2][1]== 79 && matn1[1][2]== 79 && matn1[0][3]== 79 )) // diagonal
- {
- printf("\t\t\t\t*********************************** \n");
- printf("\t\t\t\t* Parabens player 2 voce venceu!!!*\n");
- printf("\t\t\t\t***********************************\n\n");
- velha.pont2++;
- system("pause");
- return continua();
- }
- if((matn1[0][0]== 30 && matn1[0][1]== 30 && matn1[0][2]== 30 && matn1[0][3]== 30 )|| // linha // Verificar se ganhou
- (matn1[1][0]== 30 && matn1[1][1]== 30 && matn1[1][2]== 30 && matn1[1][3]== 30 )|| // linha
- (matn1[2][0]== 30 && matn1[2][1]== 30 && matn1[2][2]== 30 && matn1[2][3]== 30 )|| // linha
- (matn1[3][0]== 30 && matn1[3][1]== 30 && matn1[3][2]== 30 && matn1[3][3]== 30 )|| // linha
- (matn1[0][0]== 30 && matn1[1][0]== 30 && matn1[2][0]== 30 && matn1[3][0]== 30 )|| // coluna
- (matn1[0][1]== 30 && matn1[1][1]== 30 && matn1[2][1]== 30 && matn1[3][1]== 30 )|| // coluna
- (matn1[0][2]== 30 && matn1[1][2]== 30 && matn1[2][2]== 30 && matn1[3][2]== 30 )|| // coluna
- (matn1[0][3]== 30 && matn1[1][3]== 30 && matn1[2][3]== 30 && matn1[3][3]== 30 )|| // coluna
- (matn1[0][0]== 30 && matn1[1][1]== 30 && matn1[2][2]== 30 && matn1[3][3]== 30 )|| // diagonal
- (matn1[3][0]== 30 && matn1[2][1]== 30 && matn1[1][2]== 30 && matn1[0][3]== 30 )) // diagonal
- {
- printf("\t\t\t\t*********************************** \n");
- printf("\t\t\t\t* Parabens player 3 voce venceu!!!*\n");
- printf("\t\t\t\t***********************************\n\n");
- velha.pont3++;
- system("pause");
- return continua();
- }
- if(cont1==68){
- printf("\n\nEMPATE\n\n");
- system("pause");
- return continua();}
- break; // break do caso 1
- case 2 :
- do
- {
- printf("Em qual linha e coluna vc deseja marcar:\n");
- printf("Linha: "); // Preencher o tabuleiro
- scanf("%d",&i); // Preencher o tabuleiro
- printf("Coluna: "); // Preencher o tabuleiro
- scanf("%d",&j); // Preencher o tabuleiro
- system("cls");
- }
- 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
- matn2[i-1][j-1]= q ;
- if((matn2[0][0]== 88 && matn2[0][1]== 88 && matn2[0][2]== 88 && matn2[0][3]== 88 )|| // linha // Verificar se ganhou
- (matn2[1][0]== 88 && matn2[1][1]== 88 && matn2[1][2]== 88 && matn2[1][3]== 88 )|| // linha
- (matn2[2][0]== 88 && matn2[2][1]== 88 && matn2[2][2]== 88 && matn2[2][3]== 88 )|| // linha
- (matn2[3][0]== 88 && matn2[3][1]== 88 && matn2[3][2]== 88 && matn2[3][3]== 88 )|| // linha
- (matn2[0][0]== 88 && matn2[1][0]== 88 && matn2[2][0]== 88 && matn2[3][0]== 88 )|| // coluna
- (matn2[0][1]== 88 && matn2[1][1]== 88 && matn2[2][1]== 88 && matn2[3][1]== 88 )|| // coluna
- (matn2[0][2]== 88 && matn2[1][2]== 88 && matn2[2][2]== 88 && matn2[3][2]== 88 )|| // coluna
- (matn2[0][3]== 88 && matn2[1][3]== 88 && matn2[2][3]== 88 && matn2[3][3]== 88 )|| // coluna
- (matn2[0][0]== 88 && matn2[1][1]== 88 && matn2[2][2]== 88 && matn2[3][3]== 88 )|| // diagonal
- (matn2[3][0]== 88 && matn2[2][1]== 88 && matn2[1][2]== 88 && matn2[0][3]== 88 )) // diagonal
- {
- printf("\t\t\t\t*********************************** \n");
- printf("\t\t\t\t* Parabens player 1 voce venceu!!!*\n");
- printf("\t\t\t\t***********************************\n\n");
- velha.pont1++;
- system("pause");
- return continua();
- }
- if((matn2[0][0]== 79 && matn2[0][1]== 79 && matn2[0][2]== 79 && matn2[0][3]== 79 )|| // linha // Verificar se ganhou
- (matn2[1][0]== 79 && matn2[1][1]== 79 && matn2[1][2]== 79 && matn2[1][3]== 79 )|| // linha
- (matn2[2][0]== 79 && matn2[2][1]== 79 && matn2[2][2]== 79 && matn2[2][3]== 79 )|| // linha
- (matn2[3][0]== 79 && matn2[3][1]== 79 && matn2[3][2]== 79 && matn2[3][3]== 79 )|| // linha
- (matn2[0][0]== 79 && matn2[1][0]== 79 && matn2[2][0]== 79 && matn2[3][0]== 79 )|| // coluna
- (matn2[0][1]== 79 && matn2[1][1]== 79 && matn2[2][1]== 79 && matn2[3][1]== 79 )|| // coluna
- (matn2[0][2]== 79 && matn2[1][2]== 79 && matn2[2][2]== 79 && matn2[3][2]== 79 )|| // coluna
- (matn2[0][3]== 79 && matn2[1][3]== 79 && matn2[2][3]== 79 && matn2[3][3]== 79 )|| // coluna
- (matn2[0][0]== 79 && matn2[1][1]== 79 && matn2[2][2]== 79 && matn2[3][3]== 79 )|| // diagonal
- (matn2[3][0]== 79 && matn2[2][1]== 79 && matn2[1][2]== 79 && matn2[0][3]== 79 )) // diagonal
- {
- printf("\t\t\t\t*********************************** \n");
- printf("\t\t\t\t* Parabens player 2 voce venceu!!!*\n");
- printf("\t\t\t\t***********************************\n\n");
- velha.pont2++;
- system("pause");
- return continua();
- }
- if((matn2[0][0]== 30 && matn2[0][1]== 30 && matn2[0][2]== 30 && matn2[0][3]== 30 )|| // linha // Verificar se ganhou
- (matn2[1][0]== 30 && matn2[1][1]== 30 && matn2[1][2]== 30 && matn2[1][3]== 30 )|| // linha
- (matn2[2][0]== 30 && matn2[2][1]== 30 && matn2[2][2]== 30 && matn2[2][3]== 30 )|| // linha
- (matn2[3][0]== 30 && matn2[3][1]== 30 && matn2[3][2]== 30 && matn2[3][3]== 30 )|| // linha
- (matn2[0][0]== 30 && matn2[1][0]== 30 && matn2[2][0]== 30 && matn2[3][0]== 30 )|| // coluna
- (matn2[0][1]== 30 && matn2[1][1]== 30 && matn2[2][1]== 30 && matn2[3][1]== 30 )|| // coluna
- (matn2[0][2]== 30 && matn2[1][2]== 30 && matn2[2][2]== 30 && matn2[3][2]== 30 )|| // coluna
- (matn2[0][3]== 30 && matn2[1][3]== 30 && matn2[2][3]== 30 && matn2[3][3]== 30 )|| // coluna
- (matn2[0][0]== 30 && matn2[1][1]== 30 && matn2[2][2]== 30 && matn2[3][3]== 30 )|| // diagonal
- (matn2[3][0]== 30 && matn2[2][1]== 30 && matn2[1][2]== 30 && matn2[0][3]== 30 )) // diagonal
- {
- printf("\t\t\t\t*********************************** \n");
- printf("\t\t\t\t* Parabens player 3 voce venceu!!!*\n");
- printf("\t\t\t\t***********************************\n\n");
- velha.pont3++;
- system("pause");
- return continua();
- }
- if(cont1==68){
- printf("\n\nEMPATE\n\n");
- system("pause");
- return continua();}
- break;// break do caso 2
- case 3 :
- do
- {
- printf("Em qual linha e coluna vc deseja marcar.\n");
- printf("Linha: "); // Preencher o tabuleiro
- scanf("%d",&i); // Preencher o tabuleiro
- printf("Coluna: "); // Preencher o tabuleiro
- scanf("%d",&j); // Preencher o tabuleiro
- system("cls");
- }
- 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
- matn3[i-1][j-1]= q ;
- // condicoes matriz n3
- if((matn3[0][0]== 88 && matn3[0][1]== 88 && matn3[0][2]== 88 && matn3[0][3]== 88 )|| // linha // Verificar se ganhou
- (matn3[1][0]== 88 && matn3[1][1]== 88 && matn3[1][2]== 88 && matn3[1][3]== 88 )|| // linha
- (matn3[2][0]== 88 && matn3[2][1]== 88 && matn3[2][2]== 88 && matn3[2][3]== 88 )|| // linha
- (matn3[3][0]== 88 && matn3[3][1]== 88 && matn3[3][2]== 88 && matn3[3][3]== 88 )|| // linha
- (matn3[0][0]== 88 && matn3[1][0]== 88 && matn3[2][0]== 88 && matn3[3][0]== 88 )|| // coluna
- (matn3[0][1]== 88 && matn3[1][1]== 88 && matn3[2][1]== 88 && matn3[3][1]== 88 )|| // coluna
- (matn3[0][2]== 88 && matn3[1][2]== 88 && matn3[2][2]== 88 && matn3[3][2]== 88 )|| // coluna
- (matn3[0][3]== 88 && matn3[1][3]== 88 && matn3[2][3]== 88 && matn3[3][3]== 88 )|| // coluna
- (matn3[0][0]== 88 && matn3[1][1]== 88 && matn3[2][2]== 88 && matn3[3][3]== 88 )|| // diagonal
- (matn3[3][0]== 88 && matn3[2][1]== 88 && matn3[1][2]== 88 && matn3[0][3]== 88 )) // diagonal
- {
- printf("\t\t\t\t*********************************** \n");
- printf("\t\t\t\t* Parabens player 1 voce venceu!!!*\n");
- printf("\t\t\t\t***********************************\n\n");
- velha.pont1++;
- system("pause");
- return continua();
- }
- if ((matn3[0][0]== 79 && matn3[0][1]== 79 && matn3[0][2]== 79 && matn3[0][3]== 79 )|| // linha
- (matn3[1][0]== 79 && matn3[1][1]== 79 && matn3[1][2]== 79 && matn3[1][3]== 79 )|| // linha
- (matn3[2][0]== 79 && matn3[2][1]== 79 && matn3[2][2]== 79 && matn3[2][3]== 79 )|| // linha
- (matn3[3][0]== 79 && matn3[3][1]== 79 && matn3[3][2]== 79 && matn3[3][3]== 79 )|| // linha
- (matn3[0][0]== 79 && matn3[1][0]== 79 && matn3[2][0]== 79 && matn3[3][0]== 79 )|| // coluna
- (matn3[0][1]== 79 && matn3[1][1]== 79 && matn3[2][1]== 79 && matn3[3][1]== 79 )|| // coluna
- (matn3[0][2]== 79 && matn3[1][2]== 79 && matn3[2][2]== 79 && matn3[3][2]== 79 )|| // coluna
- (matn3[0][3]== 79 && matn3[1][3]== 79 && matn3[2][3]== 79 && matn3[3][3]== 79 )|| // coluna
- (matn3[0][0]== 79 && matn3[1][1]== 79 && matn3[2][2]== 79 && matn3[3][3]== 79 )|| // diagonal
- (matn3[3][0]== 79 && matn3[2][1]== 79 && matn3[1][2]== 79 && matn3[0][3]== 79 )) // diagonal
- {
- printf("\t\t\t\t*********************************** \n");
- printf("\t\t\t\t* Parabens player 2 voce venceu!!!*\n");
- printf("\t\t\t\t***********************************\n\n");
- velha.pont2++;
- system("pause");
- return continua();
- }
- if ((matn3[0][0]== 30 && matn3[0][1]== 30 && matn3[0][2]== 30 && matn3[0][3]== 30 )|| // linha
- (matn3[1][0]== 30 && matn3[1][1]== 30 && matn3[1][2]== 30 && matn3[1][3]== 30 )|| // linha
- (matn3[2][0]== 30 && matn3[2][1]== 30 && matn3[2][2]== 30 && matn3[2][3]== 30 )|| // linha
- (matn3[3][0]== 30 && matn3[3][1]== 30 && matn3[3][2]== 30 && matn3[3][3]== 30 )|| // linha
- (matn3[0][0]== 30 && matn3[1][0]== 30 && matn3[2][0]== 30 && matn3[3][0]== 30 )|| // coluna
- (matn3[0][1]== 30 && matn3[1][1]== 30 && matn3[2][1]== 30 && matn3[3][1]== 30 )|| // coluna
- (matn3[0][2]== 30 && matn3[1][2]== 30 && matn3[2][2]== 30 && matn3[3][2]== 30 )|| // coluna
- (matn3[0][3]== 30 && matn3[1][3]== 30 && matn3[2][3]== 30 && matn3[3][3]== 30 )|| // coluna
- (matn3[0][0]== 30 && matn3[1][1]== 30 && matn3[2][2]== 30 && matn3[3][3]== 30 )|| // diagonal
- (matn3[3][0]== 30 && matn3[2][1]== 30 && matn3[1][2]== 30 && matn3[0][3]== 30 )) // diagonal
- {
- printf("\t\t\t\t*********************************** \n");
- printf("\t\t\t\t* Parabens player 3 voce venceu!!!*\n");
- printf("\t\t\t\t***********************************\n\n");
- velha.pont3++;
- system("pause");
- return continua();
- }
- if(cont1==68){
- printf("\n\nEMPATE\n\n");
- system("pause");
- return continua();}
- break; // break do caso 3
- case 4 :
- do
- {
- printf("Em qual linha e coluna vc deseja marcar.\n");
- printf("Linha: "); // Preencher o tabuleiro
- scanf("%d",&i); // Preencher o tabuleiro
- printf("Coluna: "); // Preencher o tabuleiro
- scanf("%d",&j); // Preencher o tabuleiro
- system("cls");
- }
- 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
- matn4[i-1][j-1]= q ;
- if((matn4[0][0]== 88 && matn4[0][1]== 88 && matn4[0][2]== 88 && matn4[0][3]== 88 )|| // linha
- (matn4[1][0]== 88 && matn4[1][1]== 88 && matn4[1][2]== 88 && matn4[1][3]== 88 )|| // linha
- (matn4[2][0]== 88 && matn4[2][1]== 88 && matn4[2][2]== 88 && matn4[2][3]== 88 )|| // linha
- (matn4[3][0]== 88 && matn4[3][1]== 88 && matn4[3][2]== 88 && matn4[3][3]== 88 )|| // linha
- (matn4[0][0]== 88 && matn4[1][0]== 88 && matn4[2][0]== 88 && matn4[3][0]== 88 )|| // coluna
- (matn4[0][1]== 88 && matn4[1][1]== 88 && matn4[2][1]== 88 && matn4[3][1]== 88 )|| // coluna
- (matn4[0][2]== 88 && matn4[1][2]== 88 && matn4[2][2]== 88 && matn4[3][2]== 88 )|| // coluna
- (matn4[0][3]== 88 && matn4[1][3]== 88 && matn4[2][3]== 88 && matn4[3][3]== 88 )|| // coluna
- (matn4[0][0]== 88 && matn4[1][1]== 88 && matn4[2][2]== 88 && matn4[3][3]== 88 )|| // diagonal
- (matn4[3][0]== 88 && matn4[2][1]== 88 && matn4[1][2]== 88 && matn4[0][3]== 88 )) // diagonal
- {
- printf("\t\t\t\t*********************************** \n");
- printf("\t\t\t\t* Parabens player 1 voce venceu!!!*\n");
- printf("\t\t\t\t***********************************\n\n");
- velha.pont1++;
- system("pause");
- return continua();
- }
- if ((matn4[0][0]== 79 && matn4[0][1]== 79 && matn4[0][2]== 79 && matn4[0][3]== 79 )|| // linha
- (matn4[1][0]== 79 && matn4[1][1]== 79 && matn4[1][2]== 79 && matn4[1][3]== 79 )|| // linha
- (matn4[2][0]== 79 && matn4[2][1]== 79 && matn4[2][2]== 79 && matn4[2][3]== 79 )|| // linha
- (matn4[3][0]== 79 && matn4[3][1]== 79 && matn4[3][2]== 79 && matn4[3][3]== 79 )|| // linha
- (matn4[0][0]== 79 && matn4[1][0]== 79 && matn4[2][0]== 79 && matn4[3][0]== 79 )|| // coluna
- (matn4[0][1]== 79 && matn4[1][1]== 79 && matn4[2][1]== 79 && matn4[3][1]== 79 )|| // coluna
- (matn4[0][2]== 79 && matn4[1][2]== 79 && matn4[2][2]== 79 && matn4[3][2]== 79 )|| // coluna
- (matn4[0][3]== 79 && matn4[1][3]== 79 && matn4[2][3]== 79 && matn4[3][3]== 79 )|| // coluna
- (matn4[0][0]== 79 && matn4[1][1]== 79 && matn4[2][2]== 79 && matn4[3][3]== 79 )|| // diagonal
- (matn4[3][0]== 79 && matn4[2][1]== 79 && matn4[1][2]== 79 && matn4[0][3]== 79 )) // diagonal
- {
- printf("\t\t\t\t*********************************** \n");
- printf("\t\t\t\t* Parabens player 2 voce venceu!!!*\n");
- printf("\t\t\t\t***********************************\n\n");
- velha.pont2++;
- system("pause");
- return continua();
- }
- if ((matn4[0][0]== 30 && matn4[0][1]== 30 && matn4[0][2]== 30 && matn4[0][3]== 30 )|| // linha
- (matn4[1][0]== 30 && matn4[1][1]== 30 && matn4[1][2]== 30 && matn4[1][3]== 30 )|| // linha
- (matn4[2][0]== 30 && matn4[2][1]== 30 && matn4[2][2]== 30 && matn4[2][3]== 30 )|| // linha
- (matn4[3][0]== 30 && matn4[3][1]== 30 && matn4[3][2]== 30 && matn4[3][3]== 30 )|| // linha
- (matn4[0][0]== 30 && matn4[1][0]== 30 && matn4[2][0]== 30 && matn4[3][0]== 30 )|| // coluna
- (matn4[0][1]== 30 && matn4[1][1]== 30 && matn4[2][1]== 30 && matn4[3][1]== 30 )|| // coluna
- (matn4[0][2]== 30 && matn4[1][2]== 30 && matn4[2][2]== 30 && matn4[3][2]== 30 )|| // coluna
- (matn4[0][3]== 30 && matn4[1][3]== 30 && matn4[2][3]== 30 && matn4[3][3]== 30 )|| // coluna
- (matn4[0][0]== 30 && matn4[1][1]== 30 && matn4[2][2]== 30 && matn4[3][3]== 30 )|| // diagonal
- (matn4[3][0]== 30 && matn4[2][1]== 30 && matn4[1][2]== 30 && matn4[0][3]== 30 )) // diagonal
- {
- printf("\t\t\t\t*********************************** \n");
- printf("\t\t\t\t* Parabens player 3 voce venceu!!!*\n");
- printf("\t\t\t\t***********************************\n\n");
- velha.pont3++;
- system("pause");
- return continua();
- }
- if(cont1==68){
- printf("\n\nEMPATE\n\n");
- system("pause");
- return continua();}
- break;// break do caso 5
- } //chave do switch
- if((matn4[3][0]== 88 && matn3[3][0]== 88 && matn4[3][0]== 88 && matn1[3][0]== 88 )|| //colunaface // Teste para saber se ganhou
- (matn4[3][1]== 88 && matn3[3][1]== 88 && matn1[3][1]== 88 && matn1[3][1]== 88 )|| //colunaface
- (matn4[3][2]== 88 && matn3[3][2]== 88 && matn2[3][2]== 88 && matn1[3][2]== 88 )|| //colunaface
- (matn4[3][3]== 88 && matn3[3][3]== 88 && matn2[3][3]== 88 && matn1[3][3]== 88 )|| //colunaface
- (matn4[2][0]== 88 && matn3[2][0]== 88 && matn2[2][0]== 88 && matn1[2][0]== 88 )|| //colunaface
- (matn4[2][1]== 88 && matn3[2][1]== 88 && matn2[2][1]== 88 && matn1[2][1]== 88 )|| //colunaface
- (matn4[2][2]== 88 && matn3[2][2]== 88 && matn2[2][2]== 88 && matn1[2][2]== 88 )|| //colunaface
- (matn4[2][3]== 88 && matn3[2][3]== 88 && matn2[2][3]== 88 && matn1[2][3]== 88 )|| //colunaface
- (matn4[1][0]== 88 && matn3[1][0]== 88 && matn2[1][0]== 88 && matn1[1][0]== 88 )|| //colunaface
- (matn4[1][1]== 88 && matn3[1][1]== 88 && matn2[1][1]== 88 && matn1[1][1]== 88 )|| //colunaface
- (matn4[1][2]== 88 && matn3[1][2]== 88 && matn2[1][2]== 88 && matn1[1][2]== 88 )|| //colunaface
- (matn4[1][3]== 88 && matn3[1][3]== 88 && matn2[1][3]== 88 && matn1[1][3]== 88 )|| //colunaface
- (matn4[0][0]== 88 && matn3[0][0]== 88 && matn2[0][0]== 88 && matn1[0][0]== 88 )|| //colunaface
- (matn4[0][1]== 88 && matn3[0][1]== 88 && matn2[0][1]== 88 && matn1[0][1]== 88 )|| //colunaface
- (matn4[0][2]== 88 && matn3[0][2]== 88 && matn2[0][2]== 88 && matn1[0][2]== 88 )|| //colunaface
- (matn4[0][3]== 88 && matn3[0][3]== 88 && matn2[0][3]== 88 && matn1[0][3]== 88 )|| //colunaface
- (matn4[0][2]== 88 && matn3[0][2]== 88 && matn2[0][2]== 88 && matn1[0][2]== 88 )|| //colunaface
- (matn4[3][0]== 88 && matn3[3][1]== 88 && matn2[3][2]== 88 && matn1[3][3]== 88 )|| // \ diagonalface1
- (matn4[3][3]== 88 && matn3[3][2]== 88 && matn2[3][1]== 88 && matn1[3][0]== 88 )|| // / giagonalface1
- (matn4[2][0]== 88 && matn3[2][1]== 88 && matn2[2][2]== 88 && matn1[2][3]== 88 )|| // \ diagonalface2
- (matn4[2][3]== 88 && matn3[2][2]== 88 && matn2[2][1]== 88 && matn1[2][0]== 88 )|| // / giagonalface2
- (matn4[1][0]== 88 && matn3[1][1]== 88 && matn2[1][2]== 88 && matn1[1][3]== 88 )|| // \ diagonalface3
- (matn4[1][3]== 88 && matn3[1][2]== 88 && matn2[1][1]== 88 && matn1[1][0]== 88 )|| // \ diagonalface3
- (matn4[0][0]== 88 && matn3[0][1]== 88 && matn2[0][2]== 88 && matn1[0][3]== 88 )|| // \ diagonalface4
- (matn4[0][3]== 88 && matn3[0][2]== 88 && matn2[0][1]== 88 && matn1[0][0]== 88 )|| // \ diagonalface4
- (matn4[3][0]== 88 && matn3[2][1]== 88 && matn2[1][2]== 88 && matn1[0][3]== 88 )|| //diagonalcubo
- (matn4[3][3]== 88 && matn3[2][2]== 88 && matn2[1][1]== 88 && matn1[0][0]== 88 )|| //diagonalcubo
- (matn4[0][0]== 88 && matn3[1][1]== 88 && matn2[2][2]== 88 && matn1[3][3]== 88 )|| //diagonalcubo
- (matn4[0][3]== 88 && matn3[1][2]== 88 && matn2[2][1]== 88 && matn1[3][0]== 88 )) //diagonalcubo
- {
- printf("\t\t\t\t*********************************** \n");
- printf("\t\t\t\t* Parabens player 1 voce venceu!!!*\n");
- printf("\t\t\t\t***********************************\n\n");
- velha.pont1++;
- system("pause");
- return continua();
- }
- if((matn4[3][0]== 79 && matn3[3][0]== 79 && matn4[3][0]== 79 && matn1[3][0]== 79 )|| //colunaface // Teste para saber se ganhou
- (matn4[3][1]== 79 && matn3[3][1]== 79 && matn1[3][1]== 79 && matn1[3][1]== 79 )|| //colunaface
- (matn4[3][2]== 79 && matn3[3][2]== 79 && matn2[3][2]== 79 && matn1[3][2]== 79 )|| //colunaface
- (matn4[3][3]== 79 && matn3[3][3]== 79 && matn2[3][3]== 79 && matn1[3][3]== 79 )|| //colunaface
- (matn4[2][0]== 79 && matn3[2][0]== 79 && matn2[2][0]== 79 && matn1[2][0]== 79 )|| //colunaface
- (matn4[2][1]== 79 && matn3[2][1]== 79 && matn2[2][1]== 79 && matn1[2][1]== 79 )|| //colunaface
- (matn4[2][2]== 79 && matn3[2][2]== 79 && matn2[2][2]== 79 && matn1[2][2]== 79 )|| //colunaface
- (matn4[2][3]== 79 && matn3[2][3]== 79 && matn2[2][3]== 79 && matn1[2][3]== 79 )|| //colunaface
- (matn4[1][0]== 79 && matn3[1][0]== 79 && matn2[1][0]== 79 && matn1[1][0]== 79 )|| //colunaface
- (matn4[1][1]== 79 && matn3[1][1]== 79 && matn2[1][1]== 79 && matn1[1][1]== 79 )|| //colunaface
- (matn4[1][2]== 79 && matn3[1][2]== 79 && matn2[1][2]== 79 && matn1[1][2]== 79 )|| //colunaface
- (matn4[1][3]== 79 && matn3[1][3]== 79 && matn2[1][3]== 79 && matn1[1][3]== 79 )|| //colunaface
- (matn4[0][0]== 79 && matn3[0][0]== 79 && matn2[0][0]== 79 && matn1[0][0]== 79 )|| //colunaface
- (matn4[0][1]== 79 && matn3[0][1]== 79 && matn2[0][1]== 79 && matn1[0][1]== 79 )|| //colunaface
- (matn4[0][2]== 79 && matn3[0][2]== 79 && matn2[0][2]== 79 && matn1[0][2]== 79 )|| //colunaface
- (matn4[0][3]== 79 && matn3[0][3]== 79 && matn2[0][3]== 79 && matn1[0][3]== 79 )|| //colunaface
- (matn4[0][2]== 79 && matn3[0][2]== 79 && matn2[0][2]== 79 && matn1[0][2]== 79 )|| //colunaface
- (matn4[3][0]== 79 && matn3[3][1]== 79 && matn2[3][2]== 79 && matn1[3][3]== 79 )|| // \ diagonalface1
- (matn4[3][3]== 79 && matn3[3][2]== 79 && matn2[3][1]== 79 && matn1[3][0]== 79 )|| // / giagonalface1
- (matn4[2][0]== 79 && matn3[2][1]== 79 && matn2[2][2]== 79 && matn1[2][3]== 79 )|| // \ diagonalface2
- (matn4[2][3]== 79 && matn3[2][2]== 79 && matn2[2][1]== 79 && matn1[2][0]== 79 )|| // / giagonalface2
- (matn4[1][0]== 79 && matn3[1][1]== 79 && matn2[1][2]== 79 && matn1[1][3]== 79 )|| // \ diagonalface3
- (matn4[1][3]== 79 && matn3[1][2]== 79 && matn2[1][1]== 79 && matn1[1][0]== 79 )|| // \ diagonalface3
- (matn4[0][0]== 79 && matn3[0][1]== 79 && matn2[0][2]== 79 && matn1[0][3]== 79 )|| // \ diagonalface4
- (matn4[0][3]== 79 && matn3[0][2]== 79 && matn2[0][1]== 79 && matn1[0][0]== 79 )|| // \ diagonalface4
- (matn4[3][0]== 79 && matn3[2][1]== 79 && matn2[1][2]== 79 && matn1[0][3]== 79 )|| //diagonalcubo
- (matn4[3][3]== 79 && matn3[2][2]== 79 && matn2[1][1]== 79 && matn1[0][0]== 79 )|| //diagonalcubo
- (matn4[0][0]== 79 && matn3[1][1]== 79 && matn2[2][2]== 79 && matn1[3][3]== 79 )|| //diagonalcubo
- (matn4[0][3]== 79 && matn3[1][2]== 79 && matn2[2][1]== 79 && matn1[3][0]== 79 )) //diagonalcubo
- {
- printf("\t\t\t\t*********************************** \n");
- printf("\t\t\t\t* Parabens player 2 voce venceu!!!*\n");
- printf("\t\t\t\t***********************************\n\n");
- velha.pont2++;
- system("pause");
- return continua();
- }
- if((matn4[3][0]== 30 && matn3[3][0]== 30 && matn4[3][0]== 30 && matn1[3][0]== 30 )|| //colunaface // Teste para saber se ganhou
- (matn4[3][1]== 30 && matn3[3][1]== 30 && matn1[3][1]== 30 && matn1[3][1]== 30 )|| //colunaface
- (matn4[3][2]== 30 && matn3[3][2]== 30 && matn2[3][2]== 30 && matn1[3][2]== 30 )|| //colunaface
- (matn4[3][3]== 30 && matn3[3][3]== 30 && matn2[3][3]== 30 && matn1[3][3]== 30 )|| //colunaface
- (matn4[2][0]== 30 && matn3[2][0]== 30 && matn2[2][0]== 30 && matn1[2][0]== 30 )|| //colunaface
- (matn4[2][1]== 30 && matn3[2][1]== 30 && matn2[2][1]== 30 && matn1[2][1]== 30 )|| //colunaface
- (matn4[2][2]== 30 && matn3[2][2]== 30 && matn2[2][2]== 30 && matn1[2][2]== 30 )|| //colunaface
- (matn4[2][3]== 30 && matn3[2][3]== 30 && matn2[2][3]== 30 && matn1[2][3]== 30 )|| //colunaface
- (matn4[1][0]== 30 && matn3[1][0]== 30 && matn2[1][0]== 30 && matn1[1][0]== 30 )|| //colunaface
- (matn4[1][1]== 30 && matn3[1][1]== 30 && matn2[1][1]== 30 && matn1[1][1]== 30 )|| //colunaface
- (matn4[1][2]== 30 && matn3[1][2]== 30 && matn2[1][2]== 30 && matn1[1][2]== 30 )|| //colunaface
- (matn4[1][3]== 30 && matn3[1][3]== 30 && matn2[1][3]== 30 && matn1[1][3]== 30 )|| //colunaface
- (matn4[0][0]== 30 && matn3[0][0]== 30 && matn2[0][0]== 30 && matn1[0][0]== 30 )|| //colunaface
- (matn4[0][1]== 30 && matn3[0][1]== 30 && matn2[0][1]== 30 && matn1[0][1]== 30 )|| //colunaface
- (matn4[0][2]== 30 && matn3[0][2]== 30 && matn2[0][2]== 30 && matn1[0][2]== 30 )|| //colunaface
- (matn4[0][3]== 30 && matn3[0][3]== 30 && matn2[0][3]== 30 && matn1[0][3]== 30 )|| //colunaface
- (matn4[0][2]== 30 && matn3[0][2]== 30 && matn2[0][2]== 30 && matn1[0][2]== 30 )|| //colunaface
- (matn4[3][0]== 30 && matn3[3][1]== 30 && matn2[3][2]== 30 && matn1[3][3]== 30 )|| // \ diagonalface1
- (matn4[3][3]== 30 && matn3[3][2]== 30 && matn2[3][1]== 30 && matn1[3][0]== 30 )|| // / giagonalface1
- (matn4[2][0]== 30 && matn3[2][1]== 30 && matn2[2][2]== 30 && matn1[2][3]== 30 )|| // \ diagonalface2
- (matn4[2][3]== 30 && matn3[2][2]== 30 && matn2[2][1]== 30 && matn1[2][0]== 30 )|| // / giagonalface2
- (matn4[1][0]== 30 && matn3[1][1]== 30 && matn2[1][2]== 30 && matn1[1][3]== 30 )|| // \ diagonalface3
- (matn4[1][3]== 30 && matn3[1][2]== 30 && matn2[1][1]== 30 && matn1[1][0]== 30 )|| // \ diagonalface3
- (matn4[0][0]== 30 && matn3[0][1]== 30 && matn2[0][2]== 30 && matn1[0][3]== 30 )|| // \ diagonalface4
- (matn4[0][3]== 30 && matn3[0][2]== 30 && matn2[0][1]== 30 && matn1[0][0]== 30 )|| // \ diagonalface4
- (matn4[3][0]== 30 && matn3[2][1]== 30 && matn2[1][2]== 30 && matn1[0][3]== 30 )|| //diagonalcubo
- (matn4[3][3]== 30 && matn3[2][2]== 30 && matn2[1][1]== 30 && matn1[0][0]== 30 )|| //diagonalcubo
- (matn4[0][0]== 30 && matn3[1][1]== 30 && matn2[2][2]== 30 && matn1[3][3]== 30 )|| //diagonalcubo
- (matn4[0][3]== 30 && matn3[1][2]== 30 && matn2[2][1]== 30 && matn1[3][0]== 30 )) //diagonalcubo
- {
- printf("\t\t\t\t*********************************** \n");
- printf("\t\t\t\t* Parabens player 3 voce venceu!!!*\n");
- printf("\t\t\t\t***********************************\n\n");
- velha.pont3++;
- system("pause");
- return continua();
- }
- if(cont1==68){
- printf("\n\nEMPATE\n\n");
- system("pause");
- return continua();}
- andarn4();
- andarn3();
- andarn2();
- andarn1();
- cont1++; // contador para o primeiro if else
- }
- while (cont1<68);
- return continua();
- }
- void tutorial(){ /** Tutorial **/
- printf ("\t\t\t .----------------------. \n");
- printf ("\t\t\t | ** TUTORIAL ** | \n");
- printf ("\t\t\t `----------------------' \n\n");
- printf (" \t\t\t--- Regras: ---\n\n");
- printf (" - Este Jogo da Velha tem 3 opcoes disponiveis: Tabuleiro com 3 camadas, \n");
- printf (" tabuleiro com 4 camadas para 2 jogadores e tabuleiro com 4 camadas para 3 jogadores. \n");
- printf (" - O jogo se desenvolve com os jogadores marcando as quasas de qualquer camada. \n");
- printf (" - Eh possivel pontuar marcando 3 casas na horizontal, na vertical, na diagonal e\n");
- printf (" nas linhas em 3D, quando um jogador pontua marcando em casas diferentes.\n\n");
- printf (" - No caso dos tabuleiros com 3 camadas o jogo so acaba quando todas as casas\n");
- printf (" estiverem preenchidas. Ja no tabuleiro com 4 camadas, o jogo acaba quando qualquer");
- printf (" um dos jogadores pontuar!\n");
- system("pause");
- menu();
- }
- int menu(void)
- {
- system ("color 30");
- int opcao, op1, tab;
- char jogador;
- system("cls");
- printf("\t\t\t __ __ \n");
- printf("\t\t\t| \\/ | \n");
- printf("\t\t\t| \\ / | __ _ __ _ _ \n");
- printf("\t\t\t| |\\/| |/ _\\ '_ \\| | | |\n");
- printf("\t\t\t| | | | __/ | | | |_| |\n");
- printf("\t\t\t|_| |_|\___|_| |_|\\\__,_|\n");
- printf("\n\n");
- do{
- printf ("\t\t\t .-----------------------. \n");
- printf ("\t\t\t | * * | \n");
- printf ("\t\t\t | 1 - NOVO JOGO | \n");
- printf ("\t\t\t | 2 - SCORES | \n");
- printf ("\t\t\t | 3 - TUTORIAL | \n");
- printf ("\t\t\t | 4 - SAIR | \n");
- printf ("\t\t\t | * * | \n");
- printf ("\t\t\t `-----------------------' \n\n\n\n\n");
- scanf("%d", &opcao);
- }while(opcao != 1 && opcao != 2 && opcao != 3 && opcao != 4);
- switch(opcao)
- {
- case 1:
- do
- {
- system("cls");
- system ("color 30");
- printf ("\t\t .----------------------------------. \n");
- printf ("\t\t | ** NIVEL DE DIFICULDADE ** | \n");
- printf ("\t\t `----------------------------------' \n\n");
- printf("\t\t\t1 - Para tabuleiro com 3 camadas\n");
- printf("\n");
- printf("\t\t\t2 - Para tabuleiro com 4 camadas\n");
- scanf("%d", &tab);
- }
- while(tab!=1 && tab!=2);
- system("cls");
- system("color 30");
- if(tab==1){
- cadastro();
- system ("cls");
- system ("color 30");
- funcaojogo();
- }
- if(tab==2){
- system("cls");
- system ("color 30");
- do{
- printf ("\t\t .----------------------------------. \n");
- printf ("\t\t | ** Quantidade de Jogadores ** | \n");
- printf ("\t\t `----------------------------------' \n\n");
- printf("\t\t\t1- Para dois jogadores;\n");
- printf("\n");
- printf("\t\t\t2- Para tres jogadores;\n");
- scanf("%d", &jogador);
- }while(jogador != 1 && jogador !=2);
- if(jogador==1){
- system("cls");
- system("color 30");
- cadastro();
- system ("cls");
- system ("color 30");
- jogo();
- }
- if(jogador==2){
- system("cls");
- system("color 30");
- cadastro3();
- system ("cls");
- system ("color 30");
- jogo1();
- }
- }
- break;
- case 2:
- system("cls");
- system("color30");
- escreve();
- break;
- case 3:
- system("cls");
- tutorial();
- break;
- case 4:
- exit("menu");
- break;
- default:
- system("pause");
- printf("Opcao invalida. Tente de novo!\n");
- }
- return opcao;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement