c#输出九九乘法表

时间:2022-06-21 09:01:37
/*说在前面,为完成实验所写并保存记录,代码简单潦草,勿喷!*/
using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace MultiplicationTable{    class Program    {        static void Main(string[] args)        {            //one            Console.WriteLine("        九九乘法表");            for (int i = 1; i <= 9; i++) {                for (int j = 1; j <= 9; j++) {                    Console.Write("{0}*{1}={2,-2} ", i, j, i*j);                }                Console.WriteLine();            }            //two            Console.WriteLine("九九乘法表");            for (int i = 1; i <= 9; i++) {                for (int j = 1; j <= i; j++) {                    Console.Write("{0}*{1}={2,-2} ", i, j, i * j);                }                Console.WriteLine();            }            //three            Console.WriteLine("九九乘法表");            for (int i = 1; i <=9; i++) {                    for (int k = 0; k < i - 1; k++) {                        Console.Write("       ");                    }                    for (int j = i; j <= 9; j++)                    {                        Console.Write("{0}*{1}={2,-2} ", i, j, i * j);                    }                Console.WriteLine();            }                Console.ReadLine();        }    }}