Advertisement
legendmt25

Untitled

Dec 6th, 2019
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.18 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int n;
  8.     cin >> n;
  9.     vector <int> a;
  10.     for (size_t i{ static_cast<size_t>(n) }; i > 0; i--)
  11.     {
  12.         a.push_back(i);
  13.     }
  14.     for (size_t i{ 2 }; i <= n; i++)
  15.     {
  16.         a.push_back(i);
  17.     }
  18.     //GOREN DEL
  19.     size_t c{ 0 };
  20.     for (size_t i{ 0 }; i < (n - 1); i++, c++)
  21.     {
  22.         for (size_t j{ 0 }; j < c; j++)
  23.         {
  24.             cout << a[j] << " ";
  25.         }
  26.         for (size_t j{ 0 }; j < a.size() - (2 * c) - 1; j++)
  27.         {
  28.             cout << a[i] << " ";
  29.         }
  30.         for (size_t j{ a.size() - 1 - c }; j < a.size(); j++)
  31.         {
  32.             cout << a[j] << " ";
  33.         }
  34.         cout << endl;
  35.     }
  36.     for (auto num : a)
  37.     {
  38.         cout << num << " ";   //SREDINA
  39.     }
  40.     cout << endl;
  41.     //DOLEN DEL
  42.     c = static_cast<size_t>(n-1);
  43.     for (size_t i{ 1 }; i < n; i++, c--)
  44.     {
  45.         for (size_t j{ 0 }; j < c; j++)
  46.         {
  47.             cout << a[j] << " ";
  48.         }
  49.         for (size_t j{ 0 }; j < a.size() - 2 * c; j++)
  50.         {
  51.             cout << a[n- i - 1] << " ";
  52.         }
  53.         for (size_t j{ a.size() - c }; j < a.size(); j++)
  54.         {
  55.             cout << a[j] << " ";
  56.         }
  57.         cout << endl;
  58.     }
  59.  
  60.     return 0;
  61. }
  62. //5 4 3 2 1 2 3 4 5
  63. /*
  64. 4 4 4 4 4 4 4
  65. 4 3 3 3 3 3 4
  66. 4 3 2 2 2 3 4
  67. 4 3 2 1 2 3 4
  68. 4 3 2 2 2 3 4
  69. 4 3 3 3 3 3 4
  70. 4 4 4 4 4 4 4
  71. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement