Nested Loops Help

My arrow code is broken, please help!

I cant figure out whats wrong with the tail!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
  	//This will create the ArrowHead
	// This will create the top section of the arrow , 1 Draw char top row followed by +2 each following row
	for (int height = 1; height <= headWidth; height += 2)
	{
		//Going from bottom up minusing 2 spaces as it goes
		for (int spaces = headWidth; spaces > height; spaces -= 2)
		{
			//output spaces
			cout << " ";
		}
		for (int spaces = 0; spaces < height; spaces++)
		{
			cout << drawChar; //Prints Symbol
		}
		cout << endl;
	}

	// This will create the tail of the arrow

	//Arrow Tail
	for (int r = 0; r < tailLength; r++)
	{
		for (int c = 0; c < tailWidth; c++)
		{

			//If statement to declase what to print
			if (r == tailLength / 2)
			{
				cout << ' ';
			}
			else
			{
				cout << drawChar;
			}
		}
		cout << endl;
	}

	return 0;
}
The tailLength is wrong because the headLength is wrong. headLength = headWidth / 2 + 1.

Then the code to print the tail is too complicated. It should be like the code that prints the arrow. Figure out how many spaces and how many drawChars to print, then print them. The tail should be centered under the head. The tail is headWidth-tailWidth characters less than the head. Half of that difference should be on the right and half on the left, so the number of spaces to print is (headWidth-tailWidth)/2
Topic archived. No new replies allowed.