printing help

Nov 1, 2019 at 11:40pm
Hey guys, I am very new to c++ and needed some help with a problem I can't seem to get. I need to generate shapes, an up arrow, and a sideways arrow. I have done the side arrow with no problem ( See code ). My issue comes when I am trying to do the same thing but vertically. I have tried a multitude of ways but can't seem to figure it out. Please let me know what I can try!
Thanks in advance.
Can PM me if it's easier, I'll be checking it often.

Here is what my current code produces:

https://ibb.co/qD12mNL

And here is what I want:
https://ibb.co/hB9CpMF


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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include <iostream>
using namespace std;

int main ()
{


int i = 0;
int size = 12;
char letter = 'B';

while (i < size)
{
        //1st half of arrow
        if (i < size / 2 - 1)
        {
        int j = 0;
            do
            {
            cout << ' ';
             j++;
            }
            while (j < size / 2);

            int k = 0;
            do
            {
            cout << letter;
            k++;
            }
            while (k < i + 1);

        }
        //makes the stem
        else if (i == size / 2 - 1 || i == size / 2)
        {
        int j = 0;
            do
            {
            cout << letter;
            j++;
            }
            while (j < size);
        }
        //2nd half of arrow
        else
        {
            int j = size / 2;
            do
            {
            cout << ' ';

            j--;
            }
            while (j > 0);

            int k = size - i;
            do
            {
            cout << letter;
            k--;
            }
            while (k > 0);
        }

        //creates new line
    cout << endl;
    i++;
    }
    while (i < size);
 
}
Last edited on Nov 2, 2019 at 1:30am
Nov 2, 2019 at 12:56am
perhaps something like this will get you started ...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
int main()
{
  int l = 9;
  int r = 10;
  for(int j = 0; j < 10; j++)
  {
    for(int i = 0; i < 20; i++)
    {
      if(i >= l && i <= r)
        cout << '*';
      else cout << ' '; 
  }	  
  cout << endl;
   l--; r++;
  }		
}
Last edited on Nov 2, 2019 at 12:57am
Topic archived. No new replies allowed.