구구단 출력2

Console Programming/C# Console 2019. 9. 20. 04:31

2 x 1 =  2    3 x 1 =  3    4 x 1 =  4    5 x 1 =  5    6 x 1 =  6    7 x 1 =  7    8 x 1 =   8    9 x 1 =  9

2 x 2 =  4    3 x 2 =  6    4 x 2 =  8    5 x 2 = 10    6 x 2 = 10 ...

 

이런식으로 출력되는 프로그램

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            for (int i = 1; i < 10; i++)
            {
                for (int j = 2; j < 10; j++)
                {
                    Console.Write(String.Format("{0,1} x {1,1} = {2,2}    ", j, i, (j*i)));
                }
                Console.WriteLine();
            }
        }
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 

 

String.Format(string format, object arg0, object arg1, object arg2) 를 사용함

 

     

: