drawing shapes


how can I get the following result





1 2 3 4 5 6 7 6 5 4 3 2 1
1 2 3 4 5 6 * 6 5 4 3 2 1
1 2 3 4 5 * * * 5 4 3 2 1
1 2 3 4 * * * * * 4 3 2 1
1 2 3 * * * * * * * 3 2 1
1 2 * * * * * * * * * 2 1
1 * * * * * * * * * * * 1

code]
#include <iostream>

int main ()
{
for(int i=0;i<=12; i++)

?
?
?
}
[/code]
You're going to need two for loops.

but how can I use....
kindly help I am got confused..
I am a beginner...
Look at the pattern. You iterate up, then you iterate down and repeat until you run out of numbers. Alternatively you can have a string and modify it. Though that wouldn't be as modular in design.
Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
13
#include <iostream>
#include <stdlib.h>
using namespace std;
int main(){
for(int h = 7;h<=0;h++){
for(int i=0;i<=7;i++){

for(int k=i;k<0;k+=2){
cout<<"*"; 
}
for(int j=6;j>0;j--)
}
}


My compiler is not working kindly compile it and tell me if it is working or not.
thanka in advance.....
It's not your compiler not working. The code does not make sense and has several syntax errors.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>

using namespace std;
int main()
{
    for(int h = 7;h<=0;h++)
    {
        for(int i=0;i<=7;i++)
        {
            for(int k=i;k<0;k+=2)
            {
                cout<<"*"; 
            }
        for(int j=6;j>0;j--)
        }
Last edited on
work for the stars
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
#include <iostream>
using namespace std;

int main()
{
	int height = 7;	
	
    for(int r =1, s=0 ; r<=height; r++, s++)
    {
    	bool b = false;
    	
        for(int i=1; i<=height ; i++)
        {	
        	if(i<=height) cout << i << " "; 
        	if(i==height) 
        	{
        		for(int j=height-1; j>=1 ; j--)
        		{
        			cout << j << " ";
        		}
        	}
        }
        cout << endl;
	}
	
return 0;	
}


if still too hard,
try left sided stars first

*
**
***
****
Topic archived. No new replies allowed.