the user can type in the size range within 2 and 20, and the triangle orientation ( i.e. which direction the triangle is pointing to ), right, left, up or down. the last line of output ends with an endl
Ensure to use the correct number of spaces(s), endlines(e) and ampersands(&).
E.g., expected answer is this
&&&&&&&&&&&&&
_&&&&&&&&&&&
__&&&&&&&&&
___&&&&&&&
____&&&&&
_____&&&
______&
where those black lines are spacing. the spacing is on ONE side only, not two sides!
sample run 3: &e&&e&&&e&&&&e&&&e&&e&e
sample run 11: sss&ess&&es&&&e&&&&es&&&ess&&esss&e
- Remove any system("Pause") before submission.
- You are encouraged to use proper indentation and comments in your code.
Sample run is like:
Triangle size: 4
Triangle orientation [r, d, u, l]: r
&
&&
&&&
&&&&
&&&
&&
&
actually i wanna use for loop or while loop to do it, but still failed.
i saw a similar question on the internet but it used char which i haven't learnt yet
Two potential sources of help have asked you to show what you've tried so far, and really they can't be of much help if they don't know where you are in your learning process.
For example, if you can't use "char," what can you do?
Most people on this forum could probably write a program that does what you want, but if someone just gave it to you , how would that help you learn?
As I've told some others on this forum, your problem description is your program, just in a different language. Your job is to translate it to a form the computer can execute:
1 2 3 4 5 6 7 8 9 10 11 12 13
//the user can type in the size range within 2 and 20
code here to accept an input between 2 and 20
//and the triangle orientation
code here to accept one of four choices (r,d,u,l):
// now that you have the user's choices:
// you'll need to calculate how to change the number of spaces and &
// notice that in each line of the first example the number of spaces increases by 1 and the number of & decreases by 2
// in the second example there are no spaces, but the number of & //increases by 1 per line until it reaches 4, then decreases by 1.
// do a for() loop to create and display the spaces and &