-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
69 lines (52 loc) · 1.79 KB
/
Copy pathProgram.cs
File metadata and controls
69 lines (52 loc) · 1.79 KB
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
69
using System;
namespace MyApp
{
internal class Program
{
static void Main(string[] args)
{
//Random 클래스의 객체 r을 만든다
Random r = new Random();
//정육면체모양은 함수들이고 별표있는건 많이쓰는 함수들
//ppt참고하기
//for (int i = 0; i < 10; i++)
//{
// Console.WriteLine(r.NextDouble());
//}
//20개의 랜덤 숫자를 배열에 저장하고 최대, 최소, 평균을 계산 중요함
int[] a = new int[20]; //배열 만드는거 외우기 중요함
for(int i = 0; i<20; i++)
{
a[i] = r.Next(1,101);
Console.WriteLine("Number {0}: {1}", i + 1, a[i]);
}
int big = a[0], small = a[0], avg=0;
for(int i=0; i<20; i++)
{
if(big > a[i])
{
big = a[i];
}
if(small < a[i])
{
small = a[i];
}
avg += a[i];
}
avg /= a.Length;
Console.WriteLine("min = {0}, max = {1}, avg = {2}",big,small,avg);
Console.WriteLine(big);
Console.WriteLine(small);
Console.WriteLine(avg);
}
}
}
////foreach 쓸 때 주의점
//int[] arr = { 10, 20, 30, 40, 50 };
//for (int i = 0; i < 5; i++)
// Console.WriteLine(arr[i]);
//foreach (var i in arr)
// Console.WriteLine(i); //arr[i] 가 아님
////foreach 문장은 배열의 크기를 몰라도 사용할 수 있다. 그래서 배열과 리스트 쓸때 편하다
////Random r = new Random(); 이거 외우기
////65장에서 69장까지 클래스임