View Code of Problem 57

#include<iostream>
using namespace std;

void line(int n, int m) {
	int x = n - m;
	while (x--) cout << ' ';
	for (int i = 1; i <= m; i++) cout << i;
	for ( ;m>1; m--) cout << m-1;
	cout << endl;
}
int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)  line(n, i);
	for (int i = n-1; i ; i--)  line(n, i);
	return 0;
}

Double click to view unformatted code.


Back to problem 57