# help with empty cone

Page 1 of 1

## 4 Replies - 698 Views - Last Post: 25 October 2013 - 08:36 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=332448&amp;s=6f57d0c3bf2140dc18d207c7d2e08e14&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 michaelhammerjr

Reputation: 0
• Posts: 26
• Joined: 30-August 13

# help with empty cone

Posted 25 October 2013 - 04:40 PM

I am currently trying to make it so that this triangle/cone is empty on the inside and is not completed at the bottom. pretty much like this ^

```int n;

for(int i=1;i<=3;i++)
{
for(int sp=0; sp<=2-i; sp++)
{
cout << " ";
}
for(int j=1;j<=2*i-1;j++)
cout<<"x";
cout<<"\n";

}

```

i have tried many different for loops and placement but my shape always comes out weird looking. some redirection of advice would be appreciated

Is This A Good Question/Topic? 0

## Replies To: help with empty cone

### #2 Vaypur

Reputation: 11
• Posts: 53
• Joined: 09-October 13

## Re: help with empty cone

Posted 25 October 2013 - 06:40 PM

You are really close to getting it right. In your second for loop, consider counting backwards from your top # position. This way, it will move your #s one space back every loop. In your 3rd loop, you will need to fill out the right side of the pyramid. Since it is double side, set j<=i*2 and drop the -1. Print blanks inside your for loops. Print # just after your 2nd and 3rd for loop
```for(){
blanks
}
cout << "#";

```

After you print your # sign for your 3rd for loop, end the line.

Let me know if you need any more assistance. I hope this helped steer you in the right direction.

• D.I.C Lover

Reputation: 331
• Posts: 1,168
• Joined: 01-April 11

## Re: help with empty cone

Posted 25 October 2013 - 06:44 PM

Put your code logic into the same (strict) order as your pattern:

1) You print 0 or more spaces first

2) You print the leftmost part of the triangle

3) You print a 1 or more spaces

4) Your print the rightmost part of the triangle

You need more logic inside the outermost for loop. It's a bit easier if you use r as the iterator for the outer for loop, and c as the iterator for the inner loops. r=row, c=column.

### #4 michaelhammerjr

Reputation: 0
• Posts: 26
• Joined: 30-August 13

## Re: help with empty cone

Posted 25 October 2013 - 07:58 PM

Vaypur, on 25 October 2013 - 06:40 PM, said:

You are really close to getting it right. In your second for loop, consider counting backwards from your top # position. This way, it will move your #s one space back every loop. In your 3rd loop, you will need to fill out the right side of the pyramid. Since it is double side, set j<=i*2 and drop the -1. Print blanks inside your for loops. Print # just after your 2nd and 3rd for loop
```for(){
blanks
}
cout << "#";

```

After you print your # sign for your 3rd for loop, end the line.

Let me know if you need any more assistance. I hope this helped steer you in the right direction.

I am a little confused about what you mean by print blanks

### #5 #define

• Duke of Err

Reputation: 1853
• Posts: 6,671
• Joined: 19-February 09

## Re: help with empty cone

Posted 25 October 2013 - 08:36 PM

michaelhammerjr, on 26 October 2013 - 03:58 AM, said:

I am a little confused about what you mean by print blanks

I'm sure he means spaces.

You could use dashes (-) temporarily to analyze the problem :

2 rows uses 3 columns

```-*-
*-*
```

3 rows uses 5 columns

```--*--
-*-*-
*---*
```

4 rows uses 7 columns

```---*---
--*-*--
-*---*-
*-----*
```