Advertisement
Guest User

Untitled

a guest
Sep 20th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int n, x, y, wskaz;
  6. char c[109][109];
  7. int t[109], kierunek[5][5];
  8.  
  9. void obroc()
  10. {
  11. wskaz++;
  12. wskaz = wskaz % 4;
  13. }
  14.  
  15. void idz(int z)
  16. {
  17. for(int i = 0; i < z; i++)
  18. {
  19. x += kierunek[wskaz][0];
  20. y += kierunek[wskaz][1];
  21. c[x][y] = 'X';
  22. // cout << x << " " << y << "\n";
  23. }
  24. }
  25.  
  26. int main()
  27. {
  28. cin >> n;
  29.  
  30. t[0] = n;
  31. t[1] = n - 1;
  32. for(int i = 2; i < n; i++)
  33. {
  34. if(t[i - 2] == t[i - 1])
  35. {
  36. t[i] = t[i - 1] - 2;
  37. }
  38. else
  39. {
  40. t[i] = t[i - 1];
  41. }
  42. }
  43.  
  44. kierunek[0][0] = 1;
  45. kierunek[0][1] = 0;
  46. kierunek[1][0] = 0;
  47. kierunek[1][1] = 1;
  48. kierunek[2][0] = -1;
  49. kierunek[2][1] = 0;
  50. kierunek[3][0] = 0;
  51. kierunek[3][1] = -1;
  52.  
  53. t[0]--;
  54. c[0][0] = 'X';
  55.  
  56. for(int i = 0; i < n; i++)
  57. {
  58. idz(t[i]);
  59. obroc();
  60. }
  61.  
  62. for(int i = 0; i < n; i++)
  63. {
  64. cout << " cout << \"";
  65. for(int j = 0; j < n; j++)
  66. {
  67. if(c[i][j] == 'X')
  68. {
  69. cout << 'X';
  70. }
  71. else
  72. {
  73. cout << '.';
  74. }
  75. }
  76. cout << "\\n\"";
  77. cout << endl;
  78. }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement