Red de conocimiento informático - Material del sitio web - Cómo crear un laberinto usando programación

Cómo crear un laberinto usando programación

#incluir ltbits/stdc. h gt

# incluir ltwindows.h gt

# incluir ltconio.h gt

Usar espacio de nombres std

int main()

{

int I 123;

cout lt lt" ."

cout lt lt" .." lt ltendl

cout lt lt"?.

." lt ltendl

cout lt lt" ." lt ltendl

cout lt lt"?t M";

for(I 123 = 500;I 123 lt;=1000;i123=100){

Bip(i123, 1000);

}

Sistema("cls");

p>

char a[50][50]= { " # # # # # # # # # # # # # # # # # # # # # ",

"#o? # ## # ### ####",

"# ###### # # # # # ### ####",

" # # ## # # #### # ### ##",

"# # ##?### #?#?## ####",

"##### # ?# ##### ## ####",

"# # ##### # # # # # #", p>

"# # # ## # #### ## # # ####",

"# # # ## ?## ?# # ### #" ,

"# # # ####### ## ###### # ##",

"# # ## # ## # ## ### ### #",

"# ###### # #####?# # #",

"# # # ? ## ### ### #? ",

"# ######## ##### # ### ### # #",

"# ?# ## ##### ### ###",

"##### # ## # ?######## # #" ,

"# ?# ## ## ### # #",

"# # ### ###### ####### # ",

"# # ### ## ?# ?#",

"################### # #########"

};

int i, i1, x=1, y=1, n=12, m = 29

char ch

for(I = 0;ilt=19;i){

puts(a[I]);

}

Y (x!=n||y!=m){

? ch = getch();

if(ch = = 115 | | ch = = 25){

if(a[x 1][y]!=35){

a[x][y]= 32;

x;

a[x][y]= 111;

}

}

if(ch = = 119 | | ch = = 24){

if(a[x-1][y]!=35){

a[x][y]= 32;

x-;

a[x][y]= 111;

}

}

if(ch ==97||ch==27){

if(a[x][y-1]! =35){

a[x][y]= 32;

y-;

a[x][y]= 111; p>

}

}

>if(ch==100||ch==26){

if(a[x][y 1]!=35){

a[x][y ]= 32;

y

a[x][y]= 111;

sistema("cls");

for(I = 0;ilt=19;i){

puts(a[I]);

}

}

for(I 1 = 500;I 1 lt;=1000;i1=i1 100){

Bip(i1 , 1000

}

cout lt ltendl lt "¡¡¡Ganas!!! ¡¡¡Felicitaciones!!!"

Sistema ("pausa");

}