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
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace study_002
{
class App
{
public App()
{
string hero = "아이언맨";
string monster = "타노스";
double heroMaxHp = 10;
double heroHp;
int monsterDmage = 3;
Console.WriteLine($"{hero}의 체력은 {heroMaxHp} 입니다.");
Console.WriteLine($"{monster}의 공격력은 {monsterDmage} 입니다.");
heroHp = heroMaxHp;
for (int i = 1; i < 5; i++)
{
heroHp = heroHp - monsterDmage;
Console.WriteLine($"{hero}이 {monster}에게 {monsterDmage}의 공격을 받았습니다.");
Console.WriteLine($"{hero}의 체력은 {heroHp} 입니다.");
Console.WriteLine();
}
Console.WriteLine("ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ");
string newName = "홍길동";
Console.WriteLine("빵의 갯수는 5개 입니다.");
for (int i = 5; i > -1; i--)
{
Console.WriteLine($"{newName}님이 빵을 먹었습니다.");
Console.WriteLine($"{i}개의 빵이 남았습니다.");
}
Console.WriteLine("ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ");
for (int i=1; i<10; i++)
{
Console.WriteLine($"2 x {i}");
}
Console.WriteLine("ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ");
for (int i = 1; i < 10; i++)
{
Console.WriteLine($"2 x {i} = {2*i}");
}
}
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
|
* 결과

'c# 강의 > 과제' 카테고리의 다른 글
20200408 - 반복문 (0) | 2020.04.08 |
---|---|
20200407 - while 과제 (0) | 2020.04.07 |
20200407 - 장검 과제 (0) | 2020.04.07 |
20200406 - for문 별찍기 (0) | 2020.04.06 |
20200402 - 연산자 과제 (0) | 2020.04.02 |