Ir para conteúdo
Fórum Script Brasil

VitinhoBBK

Membros
  • Total de itens

    3
  • Registro em

  • Última visita

Sobre VitinhoBBK

VitinhoBBK's Achievements

0

Reputação

  1. for(int i=0;i<sizeof(Notas)/sizeof(Notas[0]);i++){ } Espero ter ajudado !
  2. Se poderem dar uma olhada no código abaixo e me dizer o que está causando o erro, eu agradeço demais ! Aceitos dicas/sugestões para melhorar o código também ! Obs: Estou tentando fazer um jogo da velha. (Ignorem as bibliotecas inúteis .-. ) #include <iostream> #include <stdio.h> //Para função gets #include <stdlib.h> //Para função malloc #include <math.h> #include <iomanip> //JOGO DA VELHA using namespace std; bool x=false,o=false; int jogadas=0; bool verificaX(char *vetor); bool verificaO(char *vetor); int main(){ char casas[3][3]={' ',' ',' ',' ',' ',' ',' ',' ',' '}; int l=0,c=0; while(jogadas<9){ cout << "\t\t" << casas[0][0] << " | " << casas[0][1] << " | " << casas[0][2] << "\n"; cout << "\t\t_________\n"; cout << "\t\t" << casas[1][0] << " | " << casas[1][1] << " | " << casas[1][2] << "\n"; cout << "\t\t_________\n"; cout << "\t\t" << casas[2][0] << " | " << casas[2][1] << " | " << casas[2][2] << "\n\n\n"; cout << "Digite uma linha: "; cin >> l; cout << "Digite uma coluna: "; cin >> c; while(l<=0 || c <=0 || l>3 || c>3){ system("cls"); cout << "Linha ou Coluna não existe!"; cout << "Digite uma linha: "; cin >> l; cout << "Digite uma coluna: "; cin >> c; } system("cls"); if(jogadas%2==0){ casas[--l][--c]='X'; }else{ casas[--l][--c]='O'; } jogadas++; verificaX(&casas); verificaO(&casas); } if(verificaX){ cout << "Jogador X ganhou!"; }else if(verificaO){ cout << "Jogador O ganhou!"; }else{ cout << "Empate!"; } return(0); } bool verificaX(char *vetor){ int l,c; for(l=0;l<3;l++){ if(*vetor[l][0] && *vetor[l][1] && *vetor[l][2] == 'X'){ jogadas=10; return x=true; }else if(*vetor[0][c] && *vetor[1][c] && *vetor[2][c] == 'X'){ jogadas=10; return x=true; } c++; } } bool verificaO(char *vetor){ int l,c; for(l=0;l<3;l++){ if(*vetor[l][0] && *vetor[l][1] && *vetor[l][2] == 'X'){ jogadas=10; return o=true; }else if(*vetor[0][c] && *vetor[1][c] && *vetor[2][c] == 'X'){ jogadas=10; return o=true; } c++; } }
  3. Se poderem dar uma olhada no código abaixo e me dizer o que está causando o erro, eu agradeço demais ! Obs: Estou tentando fazer um jogo da velha. (Ignorem as bibliotecas inúteis .-. ) #include <iostream> #include <stdio.h> //Para função gets #include <stdlib.h> //Para função malloc #include <math.h> #include <iomanip> //JOGO DA VELHA using namespace std; bool x=false,o=false; int jogadas=0; bool verificaX(char *vetor); bool verificaO(char *vetor); int main(){ char casas[3][3]={' ',' ',' ',' ',' ',' ',' ',' ',' '}; int l=0,c=0; while(jogadas<9){ cout << "\t\t" << casas[0][0] << " | " << casas[0][1] << " | " << casas[0][2] << "\n"; cout << "\t\t_________\n"; cout << "\t\t" << casas[1][0] << " | " << casas[1][1] << " | " << casas[1][2] << "\n"; cout << "\t\t_________\n"; cout << "\t\t" << casas[2][0] << " | " << casas[2][1] << " | " << casas[2][2] << "\n\n\n"; cout << "Digite uma linha: "; cin >> l; cout << "Digite uma coluna: "; cin >> c; while(l<=0 || c <=0 || l>3 || c>3){ system("cls"); cout << "Linha ou Coluna não existe!"; cout << "Digite uma linha: "; cin >> l; cout << "Digite uma coluna: "; cin >> c; } system("cls"); if(jogadas%2==0){ casas[--l][--c]='X'; }else{ casas[--l][--c]='O'; } jogadas++; verificaX(&casas); verificaO(&casas); } if(verificaX){ cout << "Jogador X ganhou!"; }else if(verificaO){ cout << "Jogador O ganhou!"; }else{ cout << "Empate!"; } return(0); } bool verificaX(char *vetor){ int l,c; for(l=0;l<3;l++){ if(*vetor[l][0] && *vetor[l][1] && *vetor[l][2] == 'X'){ jogadas=10; return x=true; }else if(*vetor[0][c] && *vetor[1][c] && *vetor[2][c] == 'X'){ jogadas=10; return x=true; } c++; } } bool verificaO(char *vetor){ int l,c; for(l=0;l<3;l++){ if(*vetor[l][0] && *vetor[l][1] && *vetor[l][2] == 'X'){ jogadas=10; return o=true; }else if(*vetor[0][c] && *vetor[1][c] && *vetor[2][c] == 'X'){ jogadas=10; return o=true; } c++; } }
×
×
  • Criar Novo...