Pattern problems
Sep 19, 2013 at 11:20pm UTC
Thanks as always, this is getting to be a bit much...
I dont understand why the pattern for my diamonds is staying the same, its should look like the reverse of this with the spaces increasing towards the bottom until there is only one * at the bottom with 9 spaces before it.
**********
*********
********
*******
******
*****
****
***
**
*
but it just repeats the same as the other patterns I've already made.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
#include "stdafx.h"
#include <iostream>
using namespace std;
int main()
{
int col, row, space, num2;
for (row = 1; row <= 10; row++)
{
for (col = 1; col <= row; col++)
cout << "*" ;
cout << '\n' ;
}
cout << '\n' ;
for (row = 10; row >= 1; row--)
{
for (col = 1; col <= row; col++)
cout << "*" ;
cout << '\n' ;
}
for (row = 10; row >= 1; row--)
{
for (space = 1; space <= 10 - row; space++)
{
cout << " " ;
}
cout << '\n' ;
for (col = 1; col <= row; col++)
{
cout << "*" ;
}
}
cin >> num2;
return 0;
}
Sep 19, 2013 at 11:26pm UTC
You need to move your newline on line 41 to AFTER you have printed the * to screen.
Sep 19, 2013 at 11:54pm UTC
Thanks you! Worked like a charm!
Topic archived. No new replies allowed.