Make Letters with Stars

Hi so I've been stuck for quite a while on how I would create the necessary loops to make letters with stars.

So far I've tried to draw a T, but I'm not sure how to make it work.

What I have right now is

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
   string starT(int width, int height)
    {
      string result="";
      result = "*"; // TODO: remove this line, replace with correct code

      if(((width % 2 == 1) && (width > 1)))
        {
          if(height > 1)
	    {
	      result = width * "*";
	      for(int col = 2; col <= height; col++)
	        result = ((width / 2) + 1) * " " "*";
	    }
          result += "\n";
        }

  
      return result;
    }

The basic guidelines are that the width has to an odd integer greater than or equal to 3 and height of greater than or equal to 2. For example starT(7,2) should create a
1
2
  *******
     *

I'm stuck and don't know what to do. If you guys could also guide me of how to make a C and a Z it would be highly appreciated. Making letters like L and such were a lot more simple than these letters.
Last edited on
Topic archived. No new replies allowed.