c# 打印三角菱形

//打印三角菱形
 Console.WriteLine("请输入一个数:");
                int x = Convert.ToInt32(Console.ReadLine());
                string s = "";
                string t = "Δ";
               // string p = "→_→";

                for (int k = 0; k < x; k++)//左下三角
                {
                    for (int l = 0; l <= k; l++)
                    {

                        Console.Write(t);
                    }
                    Console.WriteLine();
                }
                Console.WriteLine("--------------------");
                s = "";
                for (int m = 0; m < x; m++)//左下三角
                {
                    for (int n = m; n >= 0; n--)
                    {
                        Console.Write(t);
                    }
                    Console.WriteLine();
                }

                Console.WriteLine("--------------------");
                s = "";
                for (int mo = 0; mo < x; mo++)//左上三角
                {
                    for (int no = 0; no < x - mo; no++)
                    {
                        Console.Write(t);
                    }
                    Console.WriteLine();
                }

                Console.WriteLine("--------------------");
                s = "";
                for (int ml = 0; ml < x; ml++)//左上三角
                {
                   
                    for (int io = x - ml; io > 0; io--)
                    {

                        Console.Write(t);
                    }
                    Console.WriteLine();
                }
                Console.WriteLine("--------------------");
                s = "";
              
                for (int i = 0; i < x; i++)//尖三角形
                {
                   
                        for (int k = 0; k<x-i; k++)
                    {
                     
                             Console.Write(" ");
                     
                    }
                    s = s + t;
                            Console.Write(s);
                  
                    Console.WriteLine();
                 }
                Console.WriteLine("--------------------");
                s = "";
                for (int i = 0; i < x; i++)//右下三角
                {
                   
                    for (int k = 0; k < x - i; k++)
                    {
                       
                        Console.Write("  ");
                        

                    }
                    s = s + t;
                    Console.Write(s);

                    Console.WriteLine();
                }
                Console.WriteLine("--------------------");
                s = "";
                for (int i = 0; i < x; i++)//右上三角
                {
                   
                    for (int k = 0; k <=i; k++)
                    {
                       
                        Console.Write("  ");
                       

                    }
                    for (int k = 0; k <x- i; k++)
                    {
                  
                    Console.Write(t);
                    }
                    Console.WriteLine();
                }
                Console.WriteLine("--------------------");
                s = "";
                for (int i = 0; i < x-1; i++)//菱形上部
                {
                  
                    for (int k = x; k > i+1; k--)
                    {

                        Console.Write("  ");


                    }
                    for (int k = 2*x; k >2 * (x - i)-1; k--)
                    {

                        Console.Write(t);
                    }
                   
                     Console.WriteLine();
                }
              
                for (int i = 0; i < x; i++)//菱形下部
                {
                    for (int k = 0; k < i; k++)
                    {

                        Console.Write("  ");


                    }
                    for (int k = 0; k <2*( x - i)-1; k++)
                    {
                       
                        Console.Write(t);
                    }
                    Console.WriteLine();
                }

 


                Console.ReadKey();

转载于:https://www.cnblogs.com/lovesy2413/p/4310478.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值