質問編集履歴
2
.....
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
...........
|
test
CHANGED
@@ -1,71 +1 @@
|
|
1
|
-
入力した配列の数値を比較して、Aの数値より大きいBの数値の平均値を出したいのですが、出力結果が0になってしまいます。どこが間違っているのでしょうか?
|
2
|
-
|
3
|
-
```
|
4
|
-
|
5
|
-
#include <stdio.h>
|
6
|
-
|
7
|
-
#define N 3
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
int function(int a[], int b[])
|
12
|
-
|
13
|
-
{
|
14
|
-
|
15
|
-
double sum, count, x;
|
16
|
-
|
17
|
-
int j;
|
18
|
-
|
19
|
-
sum = 0;
|
20
|
-
|
21
|
-
count = 0;
|
22
|
-
|
23
|
-
for (j = 0; j < N; j++) {
|
24
|
-
|
25
|
-
if (a[j] < b[j] ) {
|
26
|
-
|
27
|
-
sum += b[j];
|
28
|
-
|
29
|
-
count++;
|
30
|
-
|
31
|
-
}
|
32
|
-
|
33
|
-
}
|
34
|
-
|
35
|
-
x = sum / count;
|
36
|
-
|
37
|
-
return x;
|
38
|
-
|
39
|
-
}
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
int main(void)
|
44
|
-
|
45
|
-
{
|
46
|
-
|
47
|
-
int A[N], B[N], i;
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
for (i = 0; i < N; i++){
|
52
|
-
|
53
|
-
printf("A[%d] = ?", i);
|
54
|
-
|
55
|
-
scanf("%d", &A[i]);
|
56
|
-
|
57
|
-
printf("B[%d] = ?", i);
|
58
|
-
|
59
|
-
scanf("%d", &B[i]);
|
60
|
-
|
61
|
-
}
|
62
|
-
|
63
|
-
|
1
|
+
...................................................
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
return 0;
|
68
|
-
|
69
|
-
}
|
70
|
-
|
71
|
-
```
|
1
誤字
test
CHANGED
File without changes
|
test
CHANGED
@@ -60,7 +60,7 @@
|
|
60
60
|
|
61
61
|
}
|
62
62
|
|
63
|
-
printf("ave = %f\n", function(
|
63
|
+
printf("ave = %f\n", function(A, B));
|
64
64
|
|
65
65
|
|
66
66
|
|