Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- *
- * Solution to homework assignment 1
- * Introduction to programming course
- * Faculty of Mathematics and Informatics of Sofia University
- * Winter semester 2021/2022
- *
- * @author Monika Dobrinova
- * @idnumber 8MI0600008
- * @task 1
- * @compiler VC
- *
- */
- #include <iostream>
- using namespace std;
- int main()
- {
- int n;
- cin >> n;
- if (n >= 1 && n <= 9)
- {
- for (int i = 1; i <= n; i++)
- {
- int k = 1;
- while (k < i)
- {
- cout << " ";
- k++;
- }
- for (int j = i; j <= n; j++)
- {
- cout << j;
- }
- cout << endl;
- }
- int counter = n - 1;
- for (int i = 1; i < n; i++)
- {
- for (int k = 1; k <= n - 1; k++)
- cout << " ";
- counter--;
- for (int j = n; j > counter; j--)
- {
- cout << j;
- }
- cout << endl;
- }
- }
- else
- {
- cout << "-1";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement