Programming Language/이것이 C# 연습문제 풀이
이것이 C# 5장 연습문제 풀이
dbxxrud
2019. 5. 8. 03:37
1.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
using System;
using static System.Console;
namespace Practice2
{
class MainApp
{
public static void Main()
{
for (int i = 0; i < 5; ++i)
{
for (int j = 0; j < i + 1; ++j)
Write("*");
WriteLine();
}
}
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
|
2.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
using System;
using static System.Console;
namespace Practice2
{
class MainApp
{
public static void Main()
{
for (int i = 5; i >0; --i)
{
for (int j = 0; j < i; ++j)
Write("*");
WriteLine();
}
}
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
|
3.
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 static System.Console;
namespace Practice2
{
class MainApp
{
public static void Main()
{
int i = 0;
while(i < 5)
{
int j = 0;
while (j < i + 1)
{
Write("*");
++j;
}
WriteLine();
++i;
}
}
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
|
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
|
using System;
using static System.Console;
namespace Practice2
{
class MainApp
{
public static void Main()
{
int i = 5;
do
{
int j = 0;
while (j < i)
{
Write("*");
++j;
}
WriteLine();
--i;
}
while (i > 0);
}
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
|
4.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
using System;
using static System.Console;
namespace Practice2
{
class MainApp
{
public static void Main()
{
Write("반복 횟수를 입력하세요 : ");
int inPut = int.Parse(ReadLine());
if (inPut <= 0)
WriteLine("0보다 같거나 작은 숫자는 사용할 수 없습니다.");
for (int i = 0; i < inPut; ++i)
{
for (int j = 0; j < i + 1; ++j)
Write("*");
WriteLine();
}
}
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
|