嵌套循环

复制代码
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 @   困到很想醒  阅读(8)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
点击右上角即可分享
微信分享提示