Homework

Dec 7, 2013 at 6:07pm
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 Dec 7, 2013 at 6:29pm
Dec 7, 2013 at 6:19pm
does it need to have the **** in the rows as well
Dec 7, 2013 at 6:20pm
yes in odd numbers
example
1
22
3**
4444
5****
Dec 7, 2013 at 6:27pm
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 ....
Dec 7, 2013 at 6:28pm
does it require number of columns ?
Dec 7, 2013 at 6:32pm
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 .
Dec 7, 2013 at 6:34pm
no nvm that dosnt work...
Topic archived. No new replies allowed.