I am in my 1st month of coding. I know the very basic things about it. This code is way out of my league...
I have to write a code for a diamond of asterisks. It is different than other codes i have seen on here.
It must ask the user to input the width of the diamond and the offset of the diamond. Please take a look at the code i have. Maybe experienced c++ people can help me.
If its ran in c++, i can get it to ask the user for input, but it does not make a diamond. It put many asterisks in lines.
Please help. I know it has to be some small problem but i have spent 4 hours looking for the problem and i do not understand what it could be.
* 5 space 1 *
*** 3 space 3 *
***** 1 space 5 *
*** 3 space 3 *
* 5 space 1 *
Decrement 2 space and increment 2 asterik also 1 \n after the last asterik for each line, and the opposite after reach the middle
The middle part of diamond is opposite of the first line and last line so first find how many lines that will be outputted, how ? Just count how many times you need to subract that width wth 2 til you get value 1.
Next just use for loop for(i=0;i<numof_line;i++) inside that loop create another statement to output your space, the space in the first line is equal to the diamnd width but remember to subtract that var with 2 afterwards for(j=0;j<same_as_width;j++) now for the asteriks, its equal to width - number of space form before so for(k=0;k<width_after_subtract;k++) that's my logic, I think I'll work.
For the line after the middle I think you'll figure it out by yourself, 1 more thing I don't understand that offset part