/*
* キーボードから正負の整数をデタラメに入力し、整数のみを配列に格納し、
* その個数が5個になったら入力を受け付けず、その5つの正の整数を和と
* 平均を求めるプログラムを作れ、平均は小数点以下一位まで求めろ
*/
#include <stdio.h>
#define ARRAY_SIZE (5)
int main(void)
{
int array[ARRAY_SIZE], count, i, sum;
for (count=0; count<ARRAY_SIZE; ) {
scanf("%d", &array
[count
]); if (array[count]>0)
count++;
}
for (i=0, sum=0; i<ARRAY_SIZE; i++)
sum += array[i];
printf("sum: %d, average: %d.%d\n", sum, sum/ARRAY_SIZE, (sum%ARRAY_SIZE) * 10 / ARRAY_SIZE);
return 0;
}
LyoKICog44Kt44O844Oc44O844OJ44GL44KJ5q2j6LKg44Gu5pW05pWw44KS44OH44K/44Op44Oh44Gr5YWl5Yqb44GX44CB5pW05pWw44Gu44G/44KS6YWN5YiX44Gr5qC857SN44GX44CBCiAqIOOBneOBruWAi+aVsOOBjDXlgIvjgavjgarjgaPjgZ/jgonlhaXlipvjgpLlj5fjgZHku5jjgZHjgZrjgIHjgZ3jga4144Gk44Gu5q2j44Gu5pW05pWw44KS5ZKM44GoCiAqIOW5s+Wdh+OCkuaxguOCgeOCi+ODl+ODreOCsOODqeODoOOCkuS9nOOCjOOAgeW5s+Wdh+OBr+Wwj+aVsOeCueS7peS4i+S4gOS9jeOBvuOBp+axguOCgeOCjQogKi8KI2luY2x1ZGUgPHN0ZGlvLmg+CgojZGVmaW5lIEFSUkFZX1NJWkUgKDUpCgppbnQgbWFpbih2b2lkKQp7CiAgaW50IGFycmF5W0FSUkFZX1NJWkVdLCBjb3VudCwgaSwgc3VtOwogIGZvciAoY291bnQ9MDsgY291bnQ8QVJSQVlfU0laRTsgKSB7CiAgICBzY2FuZigiJWQiLCAmYXJyYXlbY291bnRdKTsKICAgIGlmIChhcnJheVtjb3VudF0+MCkKICAgICAgY291bnQrKzsKICB9CiAgZm9yIChpPTAsIHN1bT0wOyBpPEFSUkFZX1NJWkU7IGkrKykKICAgIHN1bSArPSBhcnJheVtpXTsKICBwcmludGYoInN1bTogJWQsIGF2ZXJhZ2U6ICVkLiVkXG4iLAogICAgICAgICBzdW0sIHN1bS9BUlJBWV9TSVpFLCAoc3VtJUFSUkFZX1NJWkUpICogMTAgLyBBUlJBWV9TSVpFKTsKICByZXR1cm4gMDsKfQo=