Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- int main()
- {
- int n;
- cin >> n;
- vector <int> a;
- for (size_t i{ static_cast<size_t>(n) }; i > 0; i--)
- {
- a.push_back(i);
- }
- for (size_t i{ 2 }; i <= n; i++)
- {
- a.push_back(i);
- }
- //GOREN DEL
- size_t c{ 0 };
- for (size_t i{ 0 }; i < (n - 1); i++, c++)
- {
- for (size_t j{ 0 }; j < c; j++)
- {
- cout << a[j] << " ";
- }
- for (size_t j{ 0 }; j < a.size() - (2 * c) - 1; j++)
- {
- cout << a[i] << " ";
- }
- for (size_t j{ a.size() - 1 - c }; j < a.size(); j++)
- {
- cout << a[j] << " ";
- }
- cout << endl;
- }
- for (auto num : a)
- {
- cout << num << " "; //SREDINA
- }
- cout << endl;
- //DOLEN DEL
- c = static_cast<size_t>(n-1);
- for (size_t i{ 1 }; i < n; i++, c--)
- {
- for (size_t j{ 0 }; j < c; j++)
- {
- cout << a[j] << " ";
- }
- for (size_t j{ 0 }; j < a.size() - 2 * c; j++)
- {
- cout << a[n- i - 1] << " ";
- }
- for (size_t j{ a.size() - c }; j < a.size(); j++)
- {
- cout << a[j] << " ";
- }
- cout << endl;
- }
- return 0;
- }
- //5 4 3 2 1 2 3 4 5
- /*
- 4 4 4 4 4 4 4
- 4 3 3 3 3 3 4
- 4 3 2 2 2 3 4
- 4 3 2 1 2 3 4
- 4 3 2 2 2 3 4
- 4 3 3 3 3 3 4
- 4 4 4 4 4 4 4
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement