# Draw Rocket

Page 1 of 1

## 4 Replies - 8302 Views - Last Post: 23 October 2009 - 05:59 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=133974&amp;s=61022f964cb4085cac5a76ac26da8cef&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 gbg24

Reputation: 0
• Posts: 9
• Joined: 23-October 09

# Draw Rocket

Posted 23 October 2009 - 03:48 PM

Hello everybody,

I am working on a project for my class right now, but I am stuck. I am supposed to draw a rocket on the screen, using functional decomposition. The rocket is basically a cone, a variable number of rectangles, and another cone. The cone has to fit for all kinds of numbers. I got the part for the even numbers, but for the odd numbers it doesnt quite fit. I am supposed to have one star at the top (for the odd numbers) but I am having two. Here is the code for the odd numbers:
``` {
width=(width/2)+1;
int count,count1;
for (count=1; count<=width; count++)
{
for (count1=width-count; count1>=1; count1--)
{ cout <<" "; }
cout <<"*";
for (count1=2; count1<=count*2-2; count1++)
{cout << " "; }
cout <<"*"<<endl;}
}

```

Any hint on how to get rid of that one star would be greatly appreciated.

This is what the rocket looks like for even numbers:

Enter width of the rocket: 6
Enter height of the rocket: 7
Enter how many stages you wish to display: 2
--*--*--
-*----*-
*------*
******
*------*
*------*
*------*
*------*
*------*
******
******
*------*
*------*
*------*
*------*
*------*
******
--*--*--
-*----*-
*------*
Press any key to continue . . .
Thank you. Have a great day.

Is This A Good Question/Topic? 0

## Replies To: Draw Rocket

### #2 brds

Reputation: 76
• Posts: 515
• Joined: 22-October 08

## Re: Draw Rocket

Posted 23 October 2009 - 04:47 PM

Since you have two separate routines, even & odd, you could throw an if(row != first) on that first cout<<"*";.

### #3 gbg24

Reputation: 0
• Posts: 9
• Joined: 23-October 09

## Re: Draw Rocket

Posted 23 October 2009 - 05:00 PM

Thank you for your answer. I tried that, but it doesn't seem to work. Here is the entire function for the even/odd

```void drawCone (int width, int stages) {

if (width%2==0) {
width=width/2;
int count,count1;
for (count=1; count<=width; count++)
{
for (count1=width-count; count1>=1; count1--)
{ cout <<" "; }
cout <<"*";
for (count1=2; count1<=count*2-1; count1++)
{ cout << " "; }
cout <<"*"<<endl;}
}

else
{
width=(width/2)+1;
int count,count1;
for (count=1; count<=width; count++)
{
for (count1=width-count; count1>=1; count1--)
{ cout <<" "; }
cout <<"*";

for (count1=2; count1<=count*2-2; count1++)
{cout << " "; }
cout<< "*"<<endl;}
}
}

```

I know I have to do something to the very last 'for loop', but I'm not sure what. I tried different settings for the counters, but that doesnt work either. I'm a little confused.

### #4 brds

Reputation: 76
• Posts: 515
• Joined: 22-October 08

## Re: Draw Rocket

Posted 23 October 2009 - 05:50 PM

Funny, when I put the if statement in I get
---*---
--*-*--
etc.

### #5 gbg24

Reputation: 0
• Posts: 9
• Joined: 23-October 09

## Re: Draw Rocket

Posted 23 October 2009 - 05:59 PM

now I got it. I used the variable count1 instead of count.

Thank you for the help.

Have a nice evening.