嵌套循环

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _嵌套循环
{
    class Program
    {
        static void Main(string[] args)
        {
            //for (int j = 1; j <= 10; j++)//外层循环
            //{
            //    for (int i = 1; i <=j; i++)//内层循环
            //    {
            //        Console.Write((char)(65 + i - 1));//A是65,a是97
            //    } Console.WriteLine();
            //}
            int n, m;
            n = Convert.ToInt32(Console.ReadLine());
            m = n + 1;
            for (int j = 1; j <= m; j++)//外层循环
            {
                for (int k = 1; k <=m - j; k++)
                {
                    Console.Write(" ");
                }
                for (int i = 1; i <= j * 2 - 1; i++)//内层循环
                {
                    Console.Write("*");
                }
                Console.WriteLine();
            }
            int a=1, b=1, c=1;
            for ( a = 11; a <= 1; a--)//外层循环
            {
                for (b =11 - a; b <=1;b--)
                {
                    Console.Write(" ");
                }
                for (c = a * 2 - 1; c <= 1; c--)//内层循环
                {
                    Console.Write("*");
                }
                Console.WriteLine();
            }


        }
    }
}

 

posted @ 2024-04-09 19:16  困到很想醒  阅读(7)  评论(0编辑  收藏  举报