文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>控制台输出九九乘法表和菱形<转>

控制台输出九九乘法表和菱形<转>

时间:2011-02-27  来源:部落小头目

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            //#region 乘法口诀
            //for (int i = 1; i <= 9; i++)
            //{
            //    for (int j = 1; j <= i; j++)
            //    {
            //        Console.Write("{0}*{1}={2}" + " ", i, j, i * j);
            //    }
            //    Console.WriteLine();
            //}
            //Console.Read();
            //#endregion

            #region 菱形打印
            int i, j, k;
            Console.WriteLine("请输入正三角形的行数");
            int Q = Convert.ToInt32(Console.ReadLine());
            for (i = 1; i <= Q; i++)
            {
                for (j = 1; j <= Q - i; j++)
                {
                    Console.Write(" ");
                }
                for (k = 1; k <= 2 * i - 1; k++)
                {
                    Console.Write("*");
                }
                Console.WriteLine();
            }
            for (i = 1; i <= Q - 1; i++)
            {
                for (j = 1; j <= i; j++)
                {
                    Console.Write(" ");
                }
                for (k = 1; k <= 2 * Q - 2 * i - 1; k++)
                {
                    Console.Write("*");
                }
                Console.WriteLine();
            }
            Console.Read();
            #endregion


        }
    }
}


相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载