1. ## Diamond asterisk

Can someone help me with this problem?

write a program that prints the following diamond shape. you may use output statements that print either a single asterisk ( * ) or a single blank. maximize your use of repetition (with nested FOR structures) and minimize the number of output statements...
Code:
```      *
* * *
* * * * *
* * * * * * *
* * * * *
* * *
*```

2. That's a triangle, not a diamond. You can pass on your homework assignment by answering just that.

3. sorry
------*
----* * *
--* * * * *
* * * * * * *
--* * * * *
----* * *
------*

there u go!!

4. Ah... teacher almost fooled ya. Didn't they?

The answer you can find here: http://cboard.cprogramming.com/annou...t.php?f=3&a=39

5. yeah my gf should read that...thanx man!!

6. Originally Posted by Mario F.
That's a triangle, not a diamond. You can pass on your homework assignment by answering just that.
I've never known a Triangle to have 4 sides, I am astounded by this new feat.

I always thtought things like that were called Rhombi. (If that is the right plural?)

7. The original post was edited, bumfluff.

8. >I've never known a Triangle to have 4 sides, I am astounded by this new feat.
You missed the thread before a moderator added code tags to preserve formatting. This is how it was displayed originally:

*
* * *
* * * * *
* * * * * * *
* * * * *
* * *
*

So, where are the four sides?

9. Bumfluff obviously sees geometry in more than three dimentions, allowing him to conclude that a triangle has four sides.

10. You missed the thread before a moderator added code tags to preserve formatting.
What does it mean? What tags? When moderators will add them?

11. psychopath - what a stupid thing to say!! He sees in 4-D! The triangle obviously evolved over time to become the great and powerful diamond we see today!

12. Ok, I'm going to copy the diamond and post it (the one from the first post):

*
* * *
* * * * *
* * * * * * *
* * * * *
* * *
*

Now I'm going to do the same, but wrap CODE tags around it:

Code:
```      *
* * *
* * * * *
* * * * * * *
* * * * *
* * *
*```
Same again with Quote tags:

*
* * *
* * * * *
* * * * * * *
* * * * *
* * *
*
The code tags allows as many spaces as you desire, however, without them, the multiple spaces are deleted. Quote tags put the fancy grey background to it, but don't preserve the formatting as the code ones do.

13. I hope this is what you were looking for and helps. Let me know if you don't understand my comments. I am sure it isn't the most elegant and efficient, but I am pretty sure that it works. Has variables that easily allow you to control the height, width, and starting spot.

Code:
```#include <iostream>

using namespace std;
int main()
{
//rows for the height
//cols for the width
const int rows = 3;
const int cols = 20;

//the column you want to position the uppermost point on the screen
int startingSpot = 5;
//increment over every row
for(int i = 0; i < rows +1; i++)
{
//increment over every column of every row
for(int j = 0; j < cols; j++)
{
//if you are in the correct range
//notice that the number of asterisks on any line is a function
//of the line number you are on. Basically you print out an asterisk
//at the startingSpot of hte first line. Then the next line you print
//an asterisk out at the startingSpot and then an asterisk offset by
//1 in front of and behind. This is the i variable that tells you
//which row you are one
if(j > startingSpot - i and j < startingSpot +i)
cout<<"*";
else
cout<<" ";

cout<<" ";
}
//print out a blank line and start on the next row
cout<<endl;
}

//this does the same thing as the above code, but it prints the rows in reverse
for(int i = rows +1; i >0 ; i--)
{
for(int j = 0; j < cols; j++)
{
if(j > startingSpot - i and j < startingSpot +i)
cout<<"* ";
else
cout<<"  ";
}
cout<<endl;
}

cin.ignore();
cin.get();
}```

14. ... and this is why they say the internet is a good learning medium and every kid should have a computer to help with school.

... and why my daughter still learns from text books

15. >I am sure it isn't the most elegant and efficient
At least it's decent code. Most people who try to give free lunches can't even get hello world right.

>but I am pretty sure that it works
I'm torn between telling you it's broken and telling you to verify that it works. A good programmer has no doubts because a good programmer tests her code thoroughly before releasing it. On the other hand, if I tell you it's broken, the OP may not try to steal your code for an easy good grade. That's why we don't give out homework answers.