码迷,mamicode.com
首页 > 其他好文 > 详细

第十天学习内容 函数

时间:2015-03-13 09:18:49      阅读:132      评论:0      收藏:0      [点我收藏+]

标签:

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("\n");
            }
            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("\n");
            }
        }
        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("\n");
            }
        }
        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("\n");
            }
         
        }
        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;
            }
        }  //选择函数

    }
}

第十天学习内容 函数

标签:

原文地址:http://www.cnblogs.com/William-1234/p/4334225.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!