'전체 글'에 해당되는 글 137건

  1. 2019.09.19 2019/09/19 for 루프 1

2019/09/19 for 루프

C#/실습 2019. 9. 19. 10:58

문제 종합:

09/19 루프 예제 종합

코드:

           

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Syntax01
{
    class Program
    {
        static void Main(string[] args)
        {
            for (int counter=1; counter<=10; counter++)
            {
                Console.WriteLine("Hello World!");
            }
 
            Console.WriteLine("*** 날짜 ***");
            for (int counter=1; counter <=12; counter++)
            {
                Console.WriteLine(counter +"월");
            }
            Console.WriteLine("*** 구구단 2단 ***");
            for (int i = 1; i <= 9; i++)
            {
                Console.WriteLine($"2 X {i} = {i * 2}");
            }
            Console.WriteLine("*** 별찍기 ***");
            string a = "*";
            for (int i = 1; i<=5; i++)
            {
                Console.Write(a);
                Console.WriteLine();
                a = a + "*";
            }
            Console.WriteLine("*** 별찍기2 ***");
            string a2 = "*";
            for (int counter = 1; counter <= 4; counter++)
            {
                if (counter == 1)
                {
                    Console.Write("    ");
                }
                else if (counter == 2)
                {
                    Console.Write("   ");
                }
                else if (counter == 3)
                {
                    Console.Write("  ");
                }
                else if (counter == 4)
                {
                    Console.Write(" ");
                }
                Console.Write(a2);
                Console.WriteLine();
                a2 = a2 + "*"
            }
            Console.WriteLine("*** 별찍기3 ***");
            for (int counter = 1; counter <= 5; counter++)
            {
                Console.WriteLine("*****");
            }
        }
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
 
: