c#출력 구구단

1425 단어 c#
/*    ,            ,      ,  !*/
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();
        }
    }
}

좋은 웹페이지 즐겨찾기