Enviado em 23/06/2019 - 20:18h
galera estou tendo dificuldades para desenvolver a programação de um labirinto alguém pode me ajudar?#include <stdio.h>
#include <stdlib.h>
#define CHAO 0
#define PAREDE 1
#define VOCE 4
#define BORDA 5
#define PORTA 2
#define ENIGMA 3
#define OK 1
#define ERRO 2
#define LIMPARTELA “clear”
int coluna_atual = 4, linha_atual = 4;
int mapa[30][60] = {
5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5,
5,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5,
5,1,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,1,1,0,0,0,0,0,0,1,1,1,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5,
5,1,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,0,0,1,1,0,0,0,0,0,0,1,1,1,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5,
5,1,0,0,1,1,0,0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,1,1,0,0,1,1,1,1,0,0,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5,
5,1,0,0,1,1,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,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,1,1,1,1,1,1,1,0,0,1,1,1,1,1,5,
5,1,0,0,0,0,0,0,1,1,2,2,1,1,1,1,0,0,0,0,0,1,1,1,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5,
5,1,0,0,0,0,0,1,0,0,0,0,0,0,1,1,1,0,0,0,0,1,1,1,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5,
5,1,0,0,0,0,1,1,0,0,0,0,0,0,1,1,1,1,0,0,0,1,1,1,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5,
5,1,0,0,0,0,1,1,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5,
5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5,
5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5
};
int desenhar_mapa(){
int linha,coluna;
for (linha=0;linha<30;linha++) {
for (coluna=0;coluna<60;coluna++) {
if ((linha == linha_atual) && (coluna == coluna_atual)) {
printf("@");
continue;
}
if (mapa[linha][coluna] == CHAO)
printf(" “);
if (mapa[linha][coluna] == PAREDE)
printf(”#");
if (mapa[linha][coluna] == BORDA)
printf("#");
if (mapa[linha][coluna] == PORTA)
printf("!");
if (mapa[linha][coluna] == ENIGMA)
printf("?");
}
printf("\n");
}
return OK;
}
int main(){
char movimento;
while ((movimento != ‘x’) && (movimento != ‘X’)) {
system(LIMPARTELA);
desenhar_mapa();
printf("\n\n (W)\n(A)+(D)\n (S)\n\n");
if ((scanf("%c",&movimento))==0) {
printf(“mensagem de erro…\n”);
getchar();
return ERRO;
}
if ((movimento == ‘w’) || (movimento == ‘W’)) {
linha_atual = linha_atual - 1;
if (mapa[linha_atual][coluna_atual] != CHAO) {
linha_atual = linha_atual + 1;
printf("\n\nups.. ali não =)\n");
getchar();
}
}
if ((movimento == 's') || (movimento == 'S')) {
linha_atual = linha_atual + 1;
if (mapa[linha_atual][coluna_atual] != CHAO) {
linha_atual = linha_atual - 1;
printf("\n\nups.. ali não =)\n");
getchar();
}
}
if ((movimento == 'd') || (movimento == 'D')) {
coluna_atual = coluna_atual + 1;
if (mapa[linha_atual][coluna_atual] != CHAO) {
coluna_atual = coluna_atual - 1;
printf("\n\nups.. ali não =)\n");
getchar();
}
}
if ((movimento == 'a') || (movimento == 'A')) {
coluna_atual = coluna_atual - 1;
if (mapa[linha_atual][coluna_atual] != CHAO) {
coluna_atual = coluna_atual + 1;
printf("\n\nups.. ali não =)\n");
getchar();
}
}
}
}
Enviar mensagem ao usuário trabalhando com as opções do php.ini
Meu Fork do Plugin de Integração do CVS para o KDevelop
Compartilhando a tela do Computador no Celular via Deskreen
Como Configurar um Túnel SSH Reverso para Acessar Sua Máquina Local a Partir de uma Máquina Remota
Configuração para desligamento automatizado de Computadores em um Ambiente Comercial
Compartilhamento de Rede com samba em modo Público/Anônimo de forma simples, rápido e fácil
Cups: Mapear/listar todas as impressoras de outro Servidor CUPS de forma rápida e fácil
Criando uma VPC na AWS via CLI
Comunicação entre sede e filial (5)
Agora temos uma assistente virtual no fórum!!! (242)
Quero saber sobre os melhores aplicativos de office para usar em 2024 ... (7)