• 第十天学习内容 函数


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

    namespace day10
    {
        class Class1
        {
            static void Main(string[] args)
            {
                while (true)
                {

                   Console.WriteLine("请输入你要打印的形状:");
                    Console.WriteLine("1、方形 2、菱形 3、平行四边形");
                    Console.Write("你的选择是:");
                    int x = Convert.ToInt32(Console.ReadLine());
                    xz(x);  //进入选择(xz)函数
                    //Console.ReadKey();
                }
            }
            static public void lx(int a)   //打印菱形
            {
               
                for (int i = 1; i <= a; i++)
                {
                    for (int j = 0; j < a-i; j++)
                    {
                        Console.Write("  ");
                    }
                    for (int k = 0; k < 2*i-1; k++)
                    {
                        Console.Write("●");
                    }
                    Console.Write(" ");
                }
                for (int i = 1; i <= a; i++)
                {
                    for (int j = 1; j <= i; j++)
                    {
                        Console.Write("  ");
                    }
                    for (int k = 0; k < 2*(a-i)-1; k++)
                    {
                        Console.Write("●");
                    }
                    Console.Write(" ");
                }
            }
            static public void fx(int a ,int b)   //打印方形
            {
                for (int i = 0; i < a; i++)
                {
                    for (int j = 0; j < b; j++)
                    {
                        Console.Write("★");
                    }
                    Console.Write(" ");
                }
            }
            static public void px(int a,int b)  //打印平行四边形
            {
                for (int i = 1; i <= a; i++)
                {
                    for (int j = 1; j <= i; j++)
                    {
                        Console.Write("  ");
                    }
                    for (int k = 0; k < b; k++)
                    {
                         Console.Write("◆");
                    }
                    Console.Write(" ");
                }
             
            }
            static public void xz(int a)
            {
                switch (a)
               
                {   case 1:
                         Console.Write("请输入你要打印的方形的高:");
                        int x = Convert.ToInt32(Console.ReadLine());
             
                        Console.Write("请输入你要打印的方形的宽:");
                        int y = Convert.ToInt32(Console.ReadLine());
                        fx(x,y);
                        break;
                    case 2:
                          Console.Write("请输入你要打印的菱形的行数:");
                        int z = Convert.ToInt32(Console.ReadLine());
                        lx(z);
                        break;
                    case 3:
                          Console.Write("请输入你要打印的平行四边形的高:");
                        int c = Convert.ToInt32(Console.ReadLine());
             
                        Console.Write("请输入你要打印的平行四边形的宽:");
                        int d = Convert.ToInt32(Console.ReadLine());
                        px(c,d);
                        break;
                    default:
                        break;
                }
            }  //选择函数

        }
    }

  • 相关阅读:
    数据结构复习代码——递归实现二叉树的定义以及创建
    数据结构复习代码——递归实现广义表的创建以及遍历
    数据结构复习代码——矩阵的相关操作以及矩阵快速转置算法的实现以及遇到问题及解决
    数据结构复习代码——基于顺序存储下串的相关操作以及串匹配模式算法的实现
    Redis集群报错:(error) CROSSSLOT Keys in request don't hash to the same slot 的解决办法
    网址信息
    ERROR 1100 (HY000): Table '表名' was not locked with LOCK TABLES (表被锁定)
    java中字符串Base64、16进制的转解码函数DatatypeConverter.printBase64Binary、parseBase64Binary用法
    telnetserver安装
    基于LINUX的MySql二进制本地升级实施文档
  • 原文地址:https://www.cnblogs.com/William-1234/p/4334225.html
Copyright © 2020-2023  润新知