C# 3循环 for语句应用

时间:2022-02-18 14:42:26

class 做图形

{

static void Main(string[] args)

{

//打印下列图形

//★★★★★

//★★★★★

//★★★★★

//★★★★★

//★★★★★

// 图(一)

//     for (int i = 1; i <= 5; i++)

//     {

//         for (int j = 1; j <= 5; j++)

//         {

//             Console.Write("★");

//         }

//       Console.Write("\n");

//     }

//     Console.ReadLine();

//行   列

//★                                //1    5

//★★                              //2    4

//★★★                            //3    3

//★★★★                          //4    2

//★★★★★                        //5    1

////图(二)

//for (int i = 1; i <= 5; i++)                                                       //{

//    for (int j = 1; j <= i;j++ )

//    {

//        Console.Write("★");

//    }

//    Console.WriteLine("\n");

//}

//Console.ReadLine();

//      行  列

//★★★★★                                     //       1    5

//★★★★                                       //       2    4

//★★★                                         //       3    3

//★★                                           //       4    2

//★                                             //       5    1

//// 图(三)

//for (int i = 1; i <= 5; i++)

//{

//    for (int j = i; j <= 5; j++)

//    {

//        Console.Write("★");

//    }

//    Console.Write("\n");

//}

//       Console.ReadLine();

//☆☆☆☆★

//☆☆☆★★

//☆☆★★★

//☆★★★★

//★★★★★

////图(四)

//for (int i = 1; i <= 5;i++ )

//{

//     for(int n =1 ;n<=5-i;n++)

//for 循环里的小for循环是按照前后顺序单独进行的

//    {

//n的循环完全结束 然后进行m的循环的

//        Console.Write("☆");

//    }

//    for (int m = 1; m <= i; m++)

//    {

//        Console.Write("★");

//    }

//    Console.Write("\n");

//}

//Console.ReadLine();

//☆☆☆☆★

//☆☆☆★★★

//☆☆★★★★★

//☆★★★★★★★

//★★★★★★★★★

////图(五)

// 分析 :行(5行)和列(9列有三种符号“☆”“★”“空格”),大for里面有三个小for,

//for (int i = 1; i <= 5; i++)

//{

//    for (int a = 1; a <= 5 - i; a++)

//    {

//        Console.Write("☆");

//    }

//    for (int b = 1; b <= i; b++)

//    {

//        Console.Write("★");

//    }

//    for (int c = 1; c <= i - 1; c++)

//    {

//        Console.Write("★");

//    }

//    Console.Write("\n");

//}

//Console.ReadLine();

}

}