码迷,mamicode.com
首页 > Windows程序 > 详细

c# 菱形,三角形

时间:2015-04-19 21:05:29      阅读:345      评论:0      收藏:0      [点我收藏+]

标签:

  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();
            
            }
        }  
    }
}

 

c# 菱形,三角形

标签:

原文地址:http://www.cnblogs.com/w-wz/p/4439660.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!