回答編集履歴
1
追記
test
CHANGED
@@ -53,3 +53,83 @@
|
|
53
53
|
}
|
54
54
|
|
55
55
|
```
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
[追記] **そのものヅバリ**が欲しいって?
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
```C
|
64
|
+
|
65
|
+
#include <stdio.h>
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
void min_max_mean(int a[], int n, int *min, int *max, double *mean) {
|
70
|
+
|
71
|
+
int i;
|
72
|
+
|
73
|
+
for ( i = 0; i < n; i++) {
|
74
|
+
|
75
|
+
int value = a[i];
|
76
|
+
|
77
|
+
if ( i == 0 ) {
|
78
|
+
|
79
|
+
*min = value;
|
80
|
+
|
81
|
+
*max = value;
|
82
|
+
|
83
|
+
*mean = value;
|
84
|
+
|
85
|
+
} else {
|
86
|
+
|
87
|
+
if ( value < *min ) *min = value;
|
88
|
+
|
89
|
+
if ( value > *max ) *max = value;
|
90
|
+
|
91
|
+
*mean += value;
|
92
|
+
|
93
|
+
}
|
94
|
+
|
95
|
+
}
|
96
|
+
|
97
|
+
*mean /= n; // 最後に要素数で割る
|
98
|
+
|
99
|
+
}
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
#define SIZE 5
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
int main() {
|
108
|
+
|
109
|
+
int a[SIZE] = {45, 79, 60, 38, 55};
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
int min, max;
|
114
|
+
|
115
|
+
double mean;
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
min_max_mean(a, SIZE, &min, &max, &mean);
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
printf("min = %d\n", min);
|
124
|
+
|
125
|
+
printf("max = %d\n", max);
|
126
|
+
|
127
|
+
printf("mean = %lf\n", mean);
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
return 0;
|
132
|
+
|
133
|
+
}
|
134
|
+
|
135
|
+
```
|