Homework

I made this code with a litte help but the task is to have exact number of columns(9) , and odd numbers need to be like this
http://postimg.org/image/8ylp91bcf/
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
 
#include "stdafx.h"
#include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
if (n <= 0) return 0;
for (int r = 1; r <= n; r++) {
for (int c = 1; c <= r; c++) cout << r;
cout << endl;
}
return 0;
}
Last edited on
does it need to have the **** in the rows as well
yes in odd numbers
example
1
22
3**
4444
5****
my compiler doesn't understand #include "stdafx.h"
but if i remove that and compile i get
1
22
333
4444
55555
666666
7777777
and so on and so on ....
does it require number of columns ?
it displays as many columns as i enter... ?
if you only want 9 do you even need a user input ?
couldnt int be 9 ? instead of int n; then cin << n
?

sorry im probably confusing you more and im like yourself still learning .
no nvm that dosnt work...
Topic archived. No new replies allowed.