Advertisement
Guest User

Untitled

a guest
Jan 21st, 2019
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.34 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <cstdlib>
  4.  
  5. using namespace std;
  6. bool trafiony[10][10];
  7.  
  8. char plansza[10][10]=
  9. {
  10. {'.','.','.','.','.','.','.','.','.','.'},
  11. {'.','.','.','.','.','.','.','.','.','.'},
  12. {'.','.','.','.','.','.','.','.','.','.'},
  13. {'.','.','.','.','.','.','.','.','.','.'},
  14. {'.','.','.','.','.','.','.','.','.','.'},
  15. {'.','.','.','.','.','.','.','.','.','.'},
  16. {'.','.','.','.','.','.','.','.','.','.'},
  17. {'.','.','.','.','.','.','.','.','.','.'},
  18. {'.','.','.','.','.','.','.','.','.','.'},
  19. {'.','.','.','.','.','.','.','.','.','.'},
  20. };
  21. void wyswietlPlansze()
  22. {
  23. system ("cls");
  24. cout << " ";
  25. for (int i=1; i<=10; i++) cout << i << " ";
  26. cout << endl;
  27. for (int i=0; i<10; i++)
  28. {
  29. cout << i+1 << " ";
  30. if (i<9) cout << " ";
  31. for (int j=0; j<10; j++)
  32. cout << plansza[i][j] << " ";
  33. cout << endl;
  34. }
  35. }
  36. int main()
  37. {
  38. wyswietlPlansze();
  39. cout << endl;
  40. cout << " Instrukcja: \n 1. Na poczatku prosze zapoznac sie z instrukcja, poniewaz po pierwszym ruchu ona zniknie. \n 2. Aby rozstawic swoje statki musisz zamienic . na X w kodzie zrodlowym. \n 3. Aby wykonac ruch wpisz wartosc x - ruch w pionie, y - ruch w poziomie. \n" ;
  41. cout << endl;
  42. char strzal[10][10]=
  43. {
  44. {'.','.','.','.','.','.','.','.','.','.'}, // Tutaj zmieniaj . na X
  45. {'.','.','.','.','.','.','.','.','.','.'},
  46. {'.','.','.','.','.','.','.','.','.','.'},
  47. {'.','.','.','.','.','.','.','.','.','.'},
  48. {'.','.','.','.','.','.','.','.','.','.'},
  49. {'.','.','.','.','.','.','.','.','.','.'},
  50. {'.','.','.','.','.','.','.','.','.','.'},
  51. {'.','.','.','.','.','.','.','.','.','.'},
  52. {'.','.','.','.','.','.','.','.','.','.'},
  53. {'.','.','.','.','.','.','.','.','.','.'}
  54. };
  55. for(int i=1; i<10; i++)
  56. {
  57. for(int j=1; j<10; j++)
  58. {
  59. trafiony[i][j]=false;
  60.  
  61. int x,y;
  62. cout <<"Podaj x:";
  63. cin >> x;
  64. cout <<"Podaj y:";
  65. cin >> y;
  66. trafiony[x-1][y-1]=true;
  67. if (strzal[x-1][y-1] == '.') plansza[x-1][y-1] = 'o';
  68. else plansza[x-1][y-1] = 'X';
  69. wyswietlPlansze();
  70. }}
  71. return 0;
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement