Bing In

Bing In

  • NA
  • 30
  • 8.3k

X size pyramid

Apr 3 2016 3:14 AM
when user types number X, outputs a pyramid of size of X
if X is 6,
 
*
**
***
****
*****
******
 
using System;
class example4
{
   public static void Main()
   {
   int i;
   int j;
   int k;
   Console.WriteLine("type number of size");
   object a = (object)Console.Read();
   int b = (int) a;
   for (i = 0; i <= b;i++)
   {
      for (j = 0; j < b+1-i;j++)
               {
               Console.Write("");
               }
      for (k = 0; k < i; k++)
               {
               Console.Write("*");
               }
          Console.WriteLine("\n");
     }
}
 
but this doesn`t work
how should I solve that problem? 

Answers (2)