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

课后题 5 6

时间:2016-05-09 08:31:41      阅读:125      评论:0      收藏:0      [点我收藏+]

标签:

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();

         

           

        }
    }
}

 

课后题 5 6

标签:

原文地址:http://www.cnblogs.com/zhangdemin/p/5472556.html

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