- 4,650
- 39
I am working on a little piece of a program that prints two diagonal lines. I am using a variable "num" to specify how far down to draw each diagonal.
What I would like to do is be able to start at a position on the screen
and have the printing begin at that position, and also track the position
so that after the first diagonal line prints, the next one will start directly
under it.
Example:
if the starting position is 10, I should get this:
I know it's a simple problem, and I need a variable to store position, but I am not sure I know how to handle it after that.
right now, I can only do this
Here's what I have:
Thank you!
-MIH
What I would like to do is be able to start at a position on the screen
and have the printing begin at that position, and also track the position
so that after the first diagonal line prints, the next one will start directly
under it.
Example:
if the starting position is 10, I should get this:
Code:
*
*
*
*
*
*
right now, I can only do this
Code:
*
*
*
*
*
*
Here's what I have:
Code:
# include <iostream>
using namespace std;
main()
{
int num = 3;
for(int r = 0; r< num;++r)
{
for (int c = 0; c< r; ++c)
{
cout<<" ";
}
cout<<"*"<<endl;
}
for(int m = 1; m <= num;++m)
{
for (int c =num; c>m; --c)
{
cout<<" ";
}
cout<<"*"<<endl;
}
return 0;
}
Thank you!
-MIH