Hello Programmers! I'm currently a student at Rutgers Engineering School and I'm an EE Major. I kinda suck at programming and I'm stuck on this problem. I know how to make 4 triangles go from up to down, but I can't do it making them align next to eachother. This is my program on how it should look:
* ******************** *
** ********* ********* **
*** ******** ******** ***
**** ******* ******* ****
***** ****** ****** *****
****** ***** ***** ******
******* **** **** *******
******** *** *** ********
********* ** ** *********
*********** ***********
I am using nested for loops and my program looks like this:
*
**
***
****
*****
******
*******
********
*********
**********
**********
*********
********
*******
******
*****
****
***
**
*
**********
*********
********
*******
******
*****
****
***
**
*
*
**
***
****
*****
******
*******
********
*********
**********
This part of the lab assignemt was worth 8/10 points, which I have.
The second part is the followup assignment is where you change the program and make the triangles align side by side and it's worth only 2/10 points, the thing is i'm already handing it in late and I kinda don't have to do it because I'll only get 1 point since I'm handing it in late, but I want to know how to do it cause well it's driving me crazy! I've spent already like 2 hours trying to put them side by side when it only took me 5 min to do the other program. I don't get why it's not working, I tried getting rid of the cout << endl; but that obviously didn't work, I also tried looping the row with a for (row=1;row<=40;row++) and then nesting more for loops under it, but I get infinite loops. I'll post my program along with this.
#include <iostream>
using std::cout;
using std::endl;
int main()
{
int row;
int column;
int space;
for (row = 1; row <= 10; row++)
{
for (column = 1; column <= row; column++)
cout << "*";
cout << endl;
}
cout << endl;
for (row = 10; row >=1; row--)
{
for (column = 1; column <= row; column++)
cout << "*";
cout << endl;
}
cout << endl;
for (row = 10; row >= 1; row--)
{
for (space = 10; space >= row+1; space--)
cout << " ";
for (column = 1; column <= row; column++)
cout << "*";
cout << endl;
}
cout << endl;
for (row = 10; row >= 1; row--)
{
for (space = 1; space <= row-1; space++)
cout << " ";
for (column = 10; column >= row; column--)
cout << "*";
cout << endl;
}
cout << endl;
return 0;
}
I'm not looking for someone to rewrite my whole program, although that would be kinda nice, but I wouldn't learn anything I think I rather have a programmer give me good hints, like REALLY REALLY good hints where I can figure out what to do. I'm kind of stumped and It's like 1:40 in the mourning and I have a early class. This isn't due until the 5th, I'll be trying on my own to fix this, but I don't think I can figure this out. Anyone out there! Please help me!?!?! I'm using bloodshed Dev-C++ for my compiler. Thanks to anyone that helps out! MUCH APPRECIATED!
* ******************** *
** ********* ********* **
*** ******** ******** ***
**** ******* ******* ****
***** ****** ****** *****
****** ***** ***** ******
******* **** **** *******
******** *** *** ********
********* ** ** *********
*********** ***********
I am using nested for loops and my program looks like this:
*
**
***
****
*****
******
*******
********
*********
**********
**********
*********
********
*******
******
*****
****
***
**
*
**********
*********
********
*******
******
*****
****
***
**
*
*
**
***
****
*****
******
*******
********
*********
**********
This part of the lab assignemt was worth 8/10 points, which I have.
The second part is the followup assignment is where you change the program and make the triangles align side by side and it's worth only 2/10 points, the thing is i'm already handing it in late and I kinda don't have to do it because I'll only get 1 point since I'm handing it in late, but I want to know how to do it cause well it's driving me crazy! I've spent already like 2 hours trying to put them side by side when it only took me 5 min to do the other program. I don't get why it's not working, I tried getting rid of the cout << endl; but that obviously didn't work, I also tried looping the row with a for (row=1;row<=40;row++) and then nesting more for loops under it, but I get infinite loops. I'll post my program along with this.
#include <iostream>
using std::cout;
using std::endl;
int main()
{
int row;
int column;
int space;
for (row = 1; row <= 10; row++)
{
for (column = 1; column <= row; column++)
cout << "*";
cout << endl;
}
cout << endl;
for (row = 10; row >=1; row--)
{
for (column = 1; column <= row; column++)
cout << "*";
cout << endl;
}
cout << endl;
for (row = 10; row >= 1; row--)
{
for (space = 10; space >= row+1; space--)
cout << " ";
for (column = 1; column <= row; column++)
cout << "*";
cout << endl;
}
cout << endl;
for (row = 10; row >= 1; row--)
{
for (space = 1; space <= row-1; space++)
cout << " ";
for (column = 10; column >= row; column--)
cout << "*";
cout << endl;
}
cout << endl;
return 0;
}
I'm not looking for someone to rewrite my whole program, although that would be kinda nice, but I wouldn't learn anything I think I rather have a programmer give me good hints, like REALLY REALLY good hints where I can figure out what to do. I'm kind of stumped and It's like 1:40 in the mourning and I have a early class. This isn't due until the 5th, I'll be trying on my own to fix this, but I don't think I can figure this out. Anyone out there! Please help me!?!?! I'm using bloodshed Dev-C++ for my compiler. Thanks to anyone that helps out! MUCH APPRECIATED!