### Trouble printing an arrow

Here I've tried to separate the arrow by pritning the top part then the longest and last the opposite of the top piece. I worked my way form the inside out with the for loops but they don't seem to be coordinating correctly. Any hints so that this is printed?

 ``1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556`` ``````What I want to print: * *** *********** *** * void printArrow(int n) { for(int i = 0; i < n + 1; i++) { for(int j = 1; j < n; j += 2) { for(int k = 0;k < ((4*n+3)/2); k++) { cout << ' '; //sets the spaces } if(j == 1) cout << '*'; //prints the first start alone else { for(int h = 0; h <= j; h++) //prints the rest cout << '*'; } cout << endl; } } for(int k = n + 1; k < (4 * n + 3);k++) //middle/longest line in arrow { if(k == (4 * n + 3) - 1) //prints the last star cout << '*'; else //prints the rest cout << '*'; } for(int x = n + 1; x == 0; x--) { for(int j = 0; j < n; j -= 2) { if(j == 0) cout << '*'; //prints the last start alone else { for(int h = 0; h <= j; h++) //prints the rest cout << '*'; } cout << setw((n+1)*2) << endl; //sets the spaces cout << endl; } } ``````
Last edited on
Why don't you explain what you want the arrow to look like for 2 or 3 different given inputs?

For instance 6 and 13? What should the arrow look like for those two numbers?
oh lord, ill never understand the silly exercises they make you do to teach you loops.
Topic archived. No new replies allowed.