repetitive loop

How do you encode a program which would result to this:

1
22
333
4444
55555
4444
333
22
1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>
using namespace std;

int main(){
	int max;
	cout << "Please key in the maximum number.\n";
	cin >> max;

	for (int i=1 ; i<max ; i++){
		for (int ii=i ; ii>=1 ; ii--){
			cout << i;
		}
		cout << "\n";	
	}

	for (int n=max ; n>=1 ; n--){
		for (int nn=n ; nn>=1 ; nn--){
			cout << n;
		}
		cout << "\n";
	}

	return 0;
}


OR

1
2
3
4
5
6
7
#include <iostream>
using namespace std;

int main(){
	cout << "1\n22\n333\n4444\n55555\n4444\n333\n22\n1\n";
	return 0;
}


Hope the above can help.
i think you can write a recursive function
Topic archived. No new replies allowed.