3일차 줄넘기를 하려면 D키를 입력 해주세요. (4) d키를 입력받지 않으면 처음으로 돌아간다.
Console Programming/C# Console 2019. 9. 20. 17: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
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
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Syntax06
{
class Program
{
static void Main(string[] args)
{
Restart:
Console.WriteLine("줄넘기를 하려면 D 키를 입력 해주세요.");
ConsoleKeyInfo info = Console.ReadKey();
bool condition = info.KeyChar == 'd';
if (condition)
{
Console.Write("몇회 줄넘기를 할건가요? ");
Console.Clear();
for (int i = 1; i < count+1; i++)
{
Console.Write("줄넘기를 ");
if (i % 2 == 1)
{
Console.Write(i);
Console.ResetColor();
}
else
{
Console.Write(i);
}
Console.Write("회 했습니다.");
if (i%3 == 0)
{
Console.WriteLine(" (\"야호!\")" );
}
else
{
Console.WriteLine();
}
}
}
else
{
Console.Clear();
goto Restart;
}
}
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
|
goto를 사용하여 레이블 지정된 문으로 직접 프로그램 컨트롤을 전송합니다.
Restart라는 레이블로 지정된 곳으로 이동한다.
![](https://blog.kakaocdn.net/dn/cyvGq1/btqypyLr157/GyXNxBRf6Rd2aZ22ltQxk1/img.png)
![](https://blog.kakaocdn.net/dn/eqg3bZ/btqyo2lGJQT/gdpNRZskcxSRCySWGGH5T0/img.png)
'Console Programming > C# Console' 카테고리의 다른 글
2일차 ***별찍기2*** 의 코드 수정 (0) | 2019.09.21 |
---|---|
goto 문 (0) | 2019.09.20 |
3일차 줄넘기를 하려면 D키를 입력 해주세요. (3) 3의배수에서 야호외치기 (0) | 2019.09.20 |
3일차 줄넘기를 하려면 D키를 입력 해주세요. (2) . 홀수의 숫자 색상 바꾸기 (0) | 2019.09.20 |
3일차 줄넘기를 하려면 D키를 입력 해주세요. (0) | 2019.09.20 |