zoukankan      html  css  js  c++  java
  • 课后题 5 6

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    namespace 习题5
    {
        class Program
        {
            static void Main(string[] args)
            {
                 //打印方形,每行打印10个“A”,打印10行,使用循环嵌套,不允许定义内容为“AAAAAAAAAA”的变量;
                for (int i=1;i<=10;i++)
                {
                    for (int b = 1; b <= 10;b ++ )
                    {
                        Console.Write("A");
                    }
                    Console.WriteLine();
                }
                 Console.ReadLine(); 
    
    
                //            打印三角形
                //*
                //**
                //***
                //****
                //*****
    
                //*****
                //****
                //***
                //**
                //*
    
                //1111*
                //111**
                //11***
                //1****
                //*****
    
                //*****
                // ****
                //  ***
                //   **
                //    *
    
                //    *
                //   ***
                //  *****
                // *******
    
                //    *
                //   ***
                //  *****
                // *******
                //  *****
                //   ***
                //    *
    
                //1
                 for(int a = 1; a <= 5; a++)
                {
                    for (int b = 1; b <= a; b++)
                    {
                        Console.Write("");
                    }
                    Console.WriteLine();
                }
                Console.ReadLine();
    
    
                ////2
                for (int c = 1; c <= 5; c++)
                {
                    for (int d = 5; d >= c; d--)
                    {
                        Console.Write("");
                    }
                    Console.WriteLine();
                }
                Console.ReadLine();
    
    
                //3
                for (int a = 1; a <= 5; a++)
                {
                    for (int k = 4; k >= a; k--)
                    {
                        Console.Write("  ");
                    }
                    for (int b = 1; b <= a; b++)
                    {
                        Console.Write("");
                    }
                    Console.WriteLine();
                }
                Console.ReadLine();
    
    
                //4
                for (int a = 1; a <= 5; a++)
                {
                    for (int k = 1; k < a; k++)
                    {
                        Console.Write("  ");
                    }
                    for (int b = 5; b >= a; b--)
                    {
                        Console.Write("");
                    }
                    Console.WriteLine();
                }
                Console.ReadLine();
    
    
                //5
                for (int a = 1; a <= 4; a++)
                {
                    for (int b = 1; b <= 4 - a; b++)
                    {
                        Console.Write("  ");
                    }
                    for (int c = 1; c <= 2 * a - 1; c++)
                    {
                        Console.Write("");
                    }
                    Console.WriteLine();
                }
    
    
    
    
    
    
                   // 6
                     for (int a = 1; a <= 4; a++)
                {
                    for (int b = 1; b <= 4 - a; b++)
                    {
                        Console.Write("  ");
                    }
                    for (int c = 1; c <= 2 * a - 1; c++)
                    {
                        Console.Write("");
                    }
                    Console.WriteLine();
                }
                     for (int p = 1; p < 4; p++)
                     {
                         for (int o = 1; o <= p; o++)
                         {
                             Console.Write("  ");
                         }
                         for (int k = 1; k <= 2 * (4 - p) - 1;k++ )
                         {
                             Console.Write("");
                         }
                         Console.WriteLine();
                     }
                     Console.ReadLine();
    
             
    
               
    
            }
        }
    }
  • 相关阅读:
    WPF 自定义CheckBox样式
    WPF中的动画——(二)From/To/By 动画
    C# 异步编程
    C# 二维码生成 ( QRCoder )
    ASP.NET Core中的依赖注入(2):依赖注入(DI)
    从零搭建分布式文件系统MinIO比FastDFS要更合适
    WPF : ControlTemplate和DataTemplate的区别
    wpf 中 theme 的使用 和 listview 模板的使用.
    wpf 中的DataTemplate 绑定控件
    HTTP状态码含义
  • 原文地址:https://www.cnblogs.com/zhangdemin/p/5472556.html
Copyright © 2011-2022 走看看