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();
    
             
    
               
    
            }
        }
    }
  • 相关阅读:
    30行左右代码实现一个类似httprunner的接口框架
    Python中一些高效的数据操作
    使用jsonpath解析多层嵌套的json响应信息
    操作系统的启动流程
    I/O延迟
    存储器
    多线程和多核芯片
    CPU详解(内核态和用户态)
    操作系统
    计算机组成
  • 原文地址:https://www.cnblogs.com/zhangdemin/p/5472556.html
Copyright © 2011-2022 走看看