-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path9- (5).c
50 lines (38 loc) · 814 Bytes
/
9- (5).c
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
#include<stdio.h>
struct AvgMinMax
{
double avg;
int max, min;
};
void GetGrades(int grades[], int n);
void GetAvgMinMax(int grades[], int n, struct AvgMinMmax *AMM);
int main()
{
struct AvgMinMax x;
int arr[5];
printf("5°³ÀÇ Á¤¼ö¸¦ ÀÔ·ÂÇϽÿÀ.");
GetGrades(arr, 5);
GetAvgMinMax(arr, 5, &x);
printf("MIN : %d , AVG : %g , MAX : %d ", x.min, x.avg, x.max);
return 0;
}
void GetGrades(int grades[], int n)
{
int i;
for (i = 0;i < n;i++)
scanf("%d", &grades[i]);
}
void GetAvgMinMax(int grades[], int n, struct AvgMinMax *AMM)
{
int i;
AMM->min = grades[1];
AMM->max = grades[1];
AMM->avg = 0;
for (i = 0;i < n;i++)
{
AMM->max = (AMM->max > grades[i]) ? AMM->max : grades[i];
AMM->min = (AMM->min < grades[i]) ? AMM->min : grades[i];
AMM->avg += grades[i];
}
AMM->avg /= n;
}