• 五角星循环重难点!!!


    static void Main(string[] args)
            {
                while (true)
                {
                   
               
                /*★
                  ★★                                                    //最重要的就是找规律 i--行
                  ★★★                                                                              j--列
                  ★★★★
                  ★★★★★
                 */
               
                /*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();
                    }
                        */

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

                             else
                             {
                                 Console.Write(s);
                             }
                         }
                         Console.WriteLine();
                     }*/

                    

  • 相关阅读:
    django-02框架-配置、静态文件和路由
    django-01框架-工程搭建
    python虚拟环境安装
    linux推送文件到另一台主机
    python2问题收集
    python diff json方法
    Linux expect详解
    python scp到远端机器
    shell远程执行命令(命令行与脚本)
    git操作
  • 原文地址:https://www.cnblogs.com/lk-kk/p/4387975.html
Copyright © 2020-2023  润新知