Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- void printTiangle(int n) {
- string result = "";
- for (int i = 1; i <= n; i++) {
- for (int j = 1; j <= i; j++) {
- result += to_string(j) + " ";
- }
- result += "\n";
- }
- for (int i = n; i > 0; i--) {
- for (int j = 1; j < i; j++) {
- result += to_string(j) + " ";
- }
- result += "\n";
- }
- cout << result;
- }
- int main() {
- int n;
- cin >> n;
- printTiangle(n);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement