Fort Five
Artigos Científicos: Fort Five. Pesquise 862.000+ trabalhos acadêmicosPor: desees • 18/11/2013 • 294 Palavras (2 Páginas) • 303 Visualizações
#include <cstdlib>
#include <iostream>
#include <stdio.h>
#include <conio.h>
main()
{
int i, j, opcao=1, x=11, y=1, caminho[200][2], cont=0;
for(i=0; i<200; i++){
for(j=0; j<2; j++){
caminho[i][j] = 0;
}
}
int tabuleiro[12][12]= {0,0,0,0,0,0,0,0,0,0,3,0,
0,1,0,1,1,1,1,1,1,0,1,0,
0,1,0,1,0,0,0,0,1,0,1,0,
0,1,0,1,0,1,1,1,1,0,1,0,
0,1,1,1,0,1,0,0,0,0,1,0,
0,1,0,1,0,1,0,1,1,1,1,0,
0,1,0,1,0,1,0,1,0,0,1,0,
0,1,0,1,0,0,0,0,0,1,1,0,
0,1,0,1,0,1,1,1,0,1,0,0,
0,1,0,1,0,1,0,1,1,1,0,0,
0,1,0,1,1,1,0,1,0,1,0,0,
0,2,0,0,0,0,0,0,0,0,0,0};
for(i=0; i<12; i++){
for(j=0; j<12; j++){
if(tabuleiro[i][j]==0)
printf("###");
if(tabuleiro[i][j]==1)
printf(" ");
if(tabuleiro[i][j]==2)
printf(" %c ",1);
}
printf("\n");
}
while(opcao!=9){
printf("\n\n 8 - Cima \n 4 - Esquerda \n 6 - Direita \n 2 - Baixo\n 0 - Undo\n\n 9 - Sair\n\n Opcao: ");
scanf("%d",&opcao);
//--------------------------ANDAR PARA CIMA------------------------------------
if(opcao==8){
system("cls");
//------------IMPRIME TABULEIRO------------------
for(i=0; i<12; i++){
for(j=0; j<12; j++){
if(tabuleiro[i][j]==0)
printf("###");
if(tabuleiro[i][j]==1)
printf(" ");
if(tabuleiro[i][j]==2)
printf(" %c ",1);
}
printf("\n");
}
//-------------------------------------------------
if(tabuleiro[x-1][y] == 0 || x==0)
printf("\n -----Impossivel de andar------");
if(tabuleiro[x-1][y] == 2)
printf("\n -----Voce ja passou por este caminho------");
if(tabuleiro[x-1][y] != 0 && tabuleiro[x-1][y] != 2 && x!=0){
system("cls");
x = x - 1;
tabuleiro[x][y] = 2;
caminho[cont][0] = x;
caminho[cont][1] = y;
cont++;
for(i=0; i<12; i++){
for(j=0; j<12; j++){
if(tabuleiro[i][j]==0)
printf("###");
if(tabuleiro[i][j]==1)
printf(" ");
if(tabuleiro[i][j]==2)
printf(" %c ",1);
}
}
}
}
}
//---------------------------------ANDAR PARA DIREITA-------------------------------------
if(opcao==6){
system("cls");
//------------IMPRIME TABULEIRO------------------
for(i=0; i<12; i++){
for(j=0; j<12; j++){
if(tabuleiro[i][j]==0)
printf("###");
if(tabuleiro[i][j]==1)
printf(" ");
if(tabuleiro[i][j]==2)
printf(" %c ",1);
}
printf("\n");
}
//-------------------------------------------------
if(tabuleiro[x][y+1] == 0)
printf("\n -----Impossivel de andar------");
if(tabuleiro[x][y+1] == 2)
printf("\n
...