Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<time.h>
- #include<stdlib.h>
- using namespace std;
- long long namereniraztoqniq[20][20];
- long long razmer,randomchislo,igrachx=3,igrachy=7;
- char stena='#',puteka='.',igrach='o',pole[30][30],nakadeshtehodq;
- long long bfs(int otkudex,int otkudey)//dovurshi ot videoto
- {
- namereniraztoqniq[otkudex][otkudey]=0;
- long long spisdostx[100],spisdosty[100];
- spisdostx[0]=otkudex;
- spisdosty[0]=otkudey;
- long brdostignati=1,brobhodeni=0;
- while (brdostignati>brobhodeni)
- {
- long long obhojdanx=spisdostx[brobhodeni];
- long long obhojdany=spisdosty[brobhodeni];
- if (obhojdanx>0 && pole[obhojdanx-1][obhojdany]!=stena
- && namereniraztoqniq[obhojdanx-1][obhojdany]==-1)
- {
- namereniraztoqniq[obhojdanx-1][obhojdany]=
- 1+namereniraztoqniq[obhojdanx][obhojdany];
- spisdostx[brdostignati]=obhojdanx-1;
- spisdosty[brdostignati]=obhojdany;
- brdostignati++;
- }
- }
- }
- int main()
- {
- srand(time(NULL));
- //long long razmer,randomchislo,igrachx=3,igrachy=7;
- //char stena='#',puteka='.',igrach='o',pole[30][30],nakadeshtehodq;
- cin>>razmer;
- bool othvurlqmliq=true;
- while(othvurlqmliq)
- {
- for (int y=0; y<razmer; y++)
- {
- for (int x=0; x<razmer; x++)
- {
- randomchislo=rand()%3;
- if(randomchislo!=2)
- {
- pole[x][y]=puteka;
- }
- if(randomchislo!=1 && randomchislo!=0)
- {
- pole[x][y]=stena;
- }
- }
- }
- pole[][]
- }
- while(true)//dovurshi proverkite i opravi mesteneto na igracha
- {
- cin>>nakadeshtehodq;
- if(nakadeshtehodq=='w' && pole[igrachy-1][igrachx]!=stena)
- {
- igrachy--;
- pole[igrachx][igrachy]=puteka;
- }
- if(nakadeshtehodq=='s' && pole[igrachy+1][igrachx]!=stena)
- {
- pole[igrachx][igrachy]=puteka;
- igrachy++;
- }
- if(nakadeshtehodq=='a' && pole[igrachy][igrachx-1]!=stena)
- {
- pole[igrachx][igrachy]=puteka;
- igrachx--;
- }
- if(nakadeshtehodq=='d' && pole[igrachy][igrachx+1]!=stena)
- {
- pole[igrachx][igrachy]=puteka;
- igrachx++;
- }
- for (int y=0;y<razmer ;y++ )
- {
- for (int x=0;x<razmer ;x++ )
- {
- cout<<pole[x][y];
- pole[igrachx][igrachy]=igrach;
- }
- cout<<endl;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement