Advertisement
Guest User

Untitled

a guest
May 26th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.77 KB | None | 0 0
  1. #include<iostream>
  2. #include<time.h>
  3. #include<stdlib.h>
  4. using namespace std;
  5. long long namereniraztoqniq[20][20];
  6. long long razmer,randomchislo,igrachx=3,igrachy=7;
  7. char stena='#',puteka='.',igrach='o',pole[30][30],nakadeshtehodq;
  8. long long bfs(int otkudex,int otkudey)//dovurshi ot videoto
  9. {
  10. namereniraztoqniq[otkudex][otkudey]=0;
  11. long long spisdostx[100],spisdosty[100];
  12. spisdostx[0]=otkudex;
  13. spisdosty[0]=otkudey;
  14. long brdostignati=1,brobhodeni=0;
  15. while (brdostignati>brobhodeni)
  16. {
  17. long long obhojdanx=spisdostx[brobhodeni];
  18. long long obhojdany=spisdosty[brobhodeni];
  19. if (obhojdanx>0 && pole[obhojdanx-1][obhojdany]!=stena
  20. && namereniraztoqniq[obhojdanx-1][obhojdany]==-1)
  21. {
  22. namereniraztoqniq[obhojdanx-1][obhojdany]=
  23. 1+namereniraztoqniq[obhojdanx][obhojdany];
  24. spisdostx[brdostignati]=obhojdanx-1;
  25. spisdosty[brdostignati]=obhojdany;
  26. brdostignati++;
  27. }
  28.  
  29. }
  30. }
  31. int main()
  32. {
  33. srand(time(NULL));
  34. //long long razmer,randomchislo,igrachx=3,igrachy=7;
  35. //char stena='#',puteka='.',igrach='o',pole[30][30],nakadeshtehodq;
  36. cin>>razmer;
  37.  
  38. bool othvurlqmliq=true;
  39. while(othvurlqmliq)
  40. {
  41. for (int y=0; y<razmer; y++)
  42. {
  43. for (int x=0; x<razmer; x++)
  44. {
  45.  
  46. randomchislo=rand()%3;
  47. if(randomchislo!=2)
  48. {
  49. pole[x][y]=puteka;
  50. }
  51. if(randomchislo!=1 && randomchislo!=0)
  52. {
  53. pole[x][y]=stena;
  54. }
  55.  
  56. }
  57.  
  58. }
  59.  
  60. pole[][]
  61.  
  62.  
  63.  
  64. }
  65.  
  66.  
  67.  
  68.  
  69.  
  70. while(true)//dovurshi proverkite i opravi mesteneto na igracha
  71. {
  72. cin>>nakadeshtehodq;
  73.  
  74. if(nakadeshtehodq=='w' && pole[igrachy-1][igrachx]!=stena)
  75. {
  76. igrachy--;
  77. pole[igrachx][igrachy]=puteka;
  78. }
  79. if(nakadeshtehodq=='s' && pole[igrachy+1][igrachx]!=stena)
  80. {
  81. pole[igrachx][igrachy]=puteka;
  82. igrachy++;
  83. }
  84. if(nakadeshtehodq=='a' && pole[igrachy][igrachx-1]!=stena)
  85. {
  86. pole[igrachx][igrachy]=puteka;
  87. igrachx--;
  88. }
  89. if(nakadeshtehodq=='d' && pole[igrachy][igrachx+1]!=stena)
  90. {
  91. pole[igrachx][igrachy]=puteka;
  92. igrachx++;
  93. }
  94. for (int y=0;y<razmer ;y++ )
  95. {
  96. for (int x=0;x<razmer ;x++ )
  97. {
  98. cout<<pole[x][y];
  99. pole[igrachx][igrachy]=igrach;
  100. }
  101. cout<<endl;
  102. }
  103.  
  104. }
  105.  
  106.  
  107. return 0;
  108. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement