Having a bit of trouble trying to go about printing with for loops.
What I'm aiming for is the following...
----/----\
---/------\
--/--------\
-/----------\
Although all I can achieve so far is...
----/----\
----/----\
----/----\
The code I've put together is as follows...
(size being a user integer input)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
for (int i = 0; i < size; i++) //does (size) amount of ROWS
{
//Top line
for (int i = 0; i < size; i++) //does (size) amount of dashes
{
cout << "-";
}
cout << "/";
for (int i = 0; i < size; i++)
{
cout << "-";
}
cout << "\\" << endl;
}
So what I need to achieve is having one less dash before the "/" and two extra dashes between the "/" and "\" - for every row downwards.
If anything isn't clear just let me know and i'll try and clarify anything!
@veektorh yeah you could do it like that but I need to keep the same pattern for a user entered size. Your method would work, but only for a single size (4 in the example). If the user wanted the same shape but across 5 lines it wouldnt work as we have only told the program what to do for 4! By using for loops we can get the program to do a certain amount of iterations of a task, meaning we can scale with the users input size.