Advertisement
Guest User

Untitled

a guest
Oct 15th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. void spiral()
  2. {
  3. string tab[10][10];
  4. int szerokosc = 8;
  5. int wysokosc = 9;
  6. for (int i = 0; i < 10; i++)
  7. {
  8. for (int j = 0; j < 10; j++)
  9. {
  10. tab[i][j]=" ";
  11. }
  12.  
  13. }
  14.  
  15. int x = 0;
  16. int y = 8;
  17.  
  18. for (int i = 0; i < szerokosc; i++)
  19. {
  20. tab[x][i] = "*";
  21. }
  22.  
  23. for (int i = 0; i < wysokosc; i++)
  24. {
  25. tab[i][y] = "*";
  26. }
  27.  
  28. for (int i = 2; i < szerokosc; i++)
  29. {
  30. tab[x+8][i] = "*";
  31. }
  32.  
  33. for (int i = 1; i < wysokosc - 2; i++)
  34. {
  35. tab[i][y+4] = "*";
  36. }
  37.  
  38. int tpa = 0;
  39. int tpb = 0;
  40.  
  41. for (int i = 0; i < 2; i++)
  42. {
  43. for (int i = tpa + 3; i < szerokosc - 1; i++)
  44. {
  45. tab[x + 2][i] = "*";
  46. }
  47.  
  48. for (int i = tpb + 2; i < wysokosc - 3; i++)
  49. {
  50. tab[i][y + 8] = "*";
  51. }
  52.  
  53. szerokosc--;
  54. wysokosc--;
  55. x = x + 4;
  56. y = y - 2;
  57. tpa++;
  58. tpb++;
  59.  
  60. }
  61.  
  62.  
  63. //Wypisywanie//
  64. for (int i = 0; i < 10; i++)
  65. {
  66. for (int j = 0; j < 10; j++)
  67. {
  68. cout << tab[i][j];
  69. }
  70. cout << endl;
  71. }
  72. }
  73.  
  74. int main()
  75. {
  76. spiral();
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement