@
CheyezaM
The first row is easy: figure out how many underscores you need to print based on the user input.
The last row is similarly easy: figure out how many dots to print, then print a 'V', then print the same number of dots again.
Consider the first and last row as isolated from the rest of the problem. In other words, treat the first and last row as special cases to handle on their own, and consider the middle part separately.
Now your problem becomes: "Based on user input, how do I create this?"
\*******/
.\*****/.
..\***/..
...\*/...
Can you think of an algorithm and code something to produce this?
It may be helpful to define a function like this:
1 2 3 4 5 6 7 8
|
//printChar('Z', 5); would print ZZZZZ to the screen
void printChar(char charToPrint, int timesToPrint)
{
for(int i = 0; i < timesToPrint; i++)
{
std::cout << charToPrint;
}
}
|
so that you may concentrate on what to do in each row and not get lost in a sea of for loops.
Assuming usrInput contains user input, we could handle the last line on its own like this:
1 2 3 4 5
|
//print last row
printChar('.', usrInput);
std::cout << 'V';
printChar('.', usrInput);
std::cout << std::endl;
|