Generation

fix invalid codeTue, 02 May 2023

/****************************************************************************** Welcome to GDB Online. GDB online is an online compiler and debugger tool for C, C++, Python, PHP, Ruby, C#, OCaml, VB, Perl, Swift, Prolog, Javascript, Pascal, COBOL, HTML, CSS, JS Code, Compile, Run and Debug online from anywhere in world. *******************************************************************************/ #include <stdio.h> #include <iostream> using namespace std; const int MAX=5; int torreA[MAX]={5,4,3,2,1}; int torreB[MAX]={0,0,0,0,0}; int torreC[MAX]={0,0,0,0,0}; //função que limpa o ecrã e mostra o conteúdo das torres void mostra_torres(); //função que retira o valor do fim da torre t, substituindo por 0 //e devolve o valor retirado int retirar_da_torre(char t); //função que coloca o valor recebido no fim da torre t //se a torre t não estiver cheia void colocar_na_torre(char t, int valor); //função que verifica se a torre t está cheia bool torre_cheia(char t); int main() { setlocale(LC_ALL,"portuguese"); system("color F1"); char retirar, colocar; //de onde se retira e onde se coloca do{ mostra_torres(); cout<<"Retirar de (A/B/C): "; cin>>retirar; retirar=toupper(retirar); cout<<"Colocar em (A/B/C): "; cin>>colocar; colocar=toupper(colocar); /* 1 - Decidir se a jogada é válida*/ // contruir este código com os alunos /* 2 - Chamar aqui as repetivas funções se a jogada é válida*/ // implica construir com os alunos as funções // a) int retirar_da_torre(char t) // b) void colocar_na_torre(char t, int valor) /*o ciclo termina quando a torre C estiver cheia*/ // implica construir com os alunos a função // bool torre_cheia(char t) }while( torre_cheia('C')==false ); system("pause"); }

#include <stdio.h> using namespace std; int main() { int torreA[MAX]={5,4,3,2,1}; int torreB[MAX]={0,0,0,0,0}; int torreC[MAX]={0,0,0,0,0}; cout<<"Torre A: "; for(int i=0; i<MAX; i++){ cout<<torreA[i]; } cout<<endl<<"Torre B: "; for(int i=0; i<MAX; i++){ cout<<torreB[i]; } cout<<endl<<"Torre C: "; for(int i=0; i<MAX; i++){ cout<<torreC[i]; } return 0; }

Questions about programming?Chat with your personal AI assistant