c# 菱形,三角形

  class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {   
            /*★
              ★★
              ★★★  
              ★★★★
              ★★★★★
             */
            /*string s = "★";
            int n;
            Console.WriteLine("请输入一个数:");
            n = Convert.ToInt32(Console.ReadLine());
            for (int i = 1; i <= n; i++)
            {
                for (int j = 1; j <=i; j++)
                {
                    Console.Write(s); 
                }
                Console.WriteLine(); 
            }
                */

                /*★★★★★
                  ★★★★
                  ★★★
                  ★★
                  ★
                 */
                
                /* string s = "★";
                int n;
                Console.WriteLine("请输入一个数:");
                n = Convert.ToInt32(Console.ReadLine());
                for (int i = 1; i <= n; i++)
                {
                    for (int j = 1; j <=n+1-i; j++)
                    {
                        Console.Write(s);
                    }
                    Console.WriteLine(); 
                }
               
                */

                /*
                        ★
                      ★★
                    ★★★
                  ★★★★
                ★★★★★
                */

                /*
                  string s = "★";
                int n;
                Console.WriteLine("请输入一个数:");
                n = Convert.ToInt32(Console.ReadLine());
                for (int i = 1; i<=n; i++)
                {
                    for (int j = 1; j <=(n-i); j++)
                    {
                        Console.Write("  ");
                    }
                    for (int t = 1; t <=i ; t++)
                    {
                         Console.Write(s);
                    }
                    Console.WriteLine("");
                }
                */

                /*
                         ★
                       ★★★
                     ★★★★★ 
                   ★★★★★★★
                 ★★★★★★★★★
                */
               /*
                string s = "★";
                int n;
                Console.WriteLine("请输入一个数:");
                n = Convert.ToInt32(Console.ReadLine());
                for (int i = 1; i <=n; i++)
                {
                    for (int j = 1; j <=(n-i); j++)
                    {
                        Console.Write("  ");
                    }
                    for (int t = 1; t<=(2*i-1);t++)
                    {
                        Console.Write(s);
                    }
                    Console.WriteLine();
                }
                */
                /*
                    ★
                   ★★
                  ★★★
                 ★★★★
                ★★★★★  
                 ★★★★
                  ★★★
                   ★★
                    ★
                */
               /* string s = "★";
                int n;
                Console.WriteLine("请输入一个数:");
                n = Convert.ToInt32(Console.ReadLine());
                for (int i = 1; i <=n; i++)
                { 
                        for (int b = 1; b <=n-i; b++)
                      {
                        Console.Write(" ");
                      }
                    for (int j= 1; j <=i; j++)
                      {
                         Console.Write(s);
                         ;
                      }
                    Console.WriteLine();
                }
                    for (int p = 1; p <=n; p++)
                    {
                        for (int o = 1; o <=p; o++)
                        {
                            Console.Write(" ");
                        }
                        for (int k = 1; k <=n-p; k++)
                        {
                             Console.Write(s);
                        }
                        Console.WriteLine();
                    }
                        
                    Console.WriteLine();
                /*
                 ★
               ★★★
             ★★★★★
               ★★★
                 ★
                 */
               string s = "";
                int n;
                Console.WriteLine("请输入一个数:");
                n = Convert.ToInt32(Console.ReadLine());

                for (int i = 1; i <=n; i++)
                {
                    for (int x = 1; x <=n-i; x++)
                    {
                        Console.Write("  ");
                    }
                    for (int y = 1; y <=2*i-1; y++)
                    {
                        Console.Write(s);
                    }   
                    
                    Console.WriteLine();
                }
                for (int t = 1; t <n; t++)
                {
                    for (int z = 1; z <=t; z++)
                    {
                        Console.Write("  ");
                    }
                    for (int q = 1; q <=2*(n-t)-1; q++)//最重要的公式!!
                    {
                         Console.Write(s);
                    }
                    Console.WriteLine();
                }
                
                /*
                 ★★
                ★★★
               ★★★★
              ★★★★★
                */

                 /*string s = "★";
                int n;
                Console.WriteLine("请输入一个数(大于4):");
                n = Convert.ToInt32(Console.ReadLine());
                for (int i = 4; i <= n; i++)
                {
                    for (int j = 1; j <= (n - i); j++)
                    {
                        Console.Write("  ");
                    }
                    for (int t = 1; t <= (2 * i-1); t++)
                    {
                        Console.Write(s);
                    }
                    Console.WriteLine();
                }
                    */
            Console.ReadLine();
            
            }
        }  
    }
}

 

posted @ 2015-04-19 19:14  王文姿  阅读(581)  评论(0编辑  收藏  举报