#include <stdio.h>
int main()
{
int tokuten[5]; /* 得点保存用の配列 */
int i; /* ループ変数 */
int sum=0; /* 全科目の点数合計 */
int sum_gokaku=0; /* 合格科目の点数合計 */
int c=0; /* 合格科目の数 */
float avg=0; /* 全科目の平均点 */
float avg_gokaku=0; /* 合格科目の平均点 */
for(i=0; i<5; i++) { /* 5科目の点数入力ループ */
sum+=tokuten[i]; /* 全科目の点数合計に加算 */
if(tokuten[i]>=60) { /* 合格科目か? */
c++; /* 合格科目の数を+1 */
sum_gokaku+=tokuten[i]; /* 合格科目の点数合計に加算 */
}
}
if(c) { /* 合格科目があるか? */
printf("合格科目は%d科目で合格科目の合計は%d点です\n",c
,sum_gokaku
); avg_gokaku=sum_gokaku/1.0/c; /* 合格科目の平均点計算 */
printf("合格科目の平均は%.1f点です\n",avg_gokaku
); } else { /* 合格科目が無い場合 */
printf("合格科目は%d科目で合格科目の合計は%d点です\n",0,0); }
printf("全科目は%d科目で合格科目の合計は%d点です\n",5,sum
); avg=sum/5.0; /* 全科目の平均点計算 */
printf("全科目の平均は%.1f点です\n",avg
);
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CgppbnQgbWFpbigpCnsKICBpbnQgdG9rdXRlbls1XTsJCS8qIOW+l+eCueS/neWtmOeUqOOBrumFjeWIlyAqLwogIGludCBpOwkJCS8qIOODq+ODvOODl+WkieaVsCAqLwogIGludCBzdW09MDsJCQkvKiDlhajnp5Hnm67jga7ngrnmlbDlkIjoqIggKi8KICBpbnQgc3VtX2dva2FrdT0wOwkJLyog5ZCI5qC856eR55uu44Gu54K55pWw5ZCI6KiIICovCiAgaW50IGM9MDsJCQkvKiDlkIjmoLznp5Hnm67jga7mlbAgKi8KICBmbG9hdCBhdmc9MDsJCQkvKiDlhajnp5Hnm67jga7lubPlnYfngrkgKi8KICBmbG9hdCBhdmdfZ29rYWt1PTA7CQkvKiDlkIjmoLznp5Hnm67jga7lubPlnYfngrkgKi8KCiAgZm9yKGk9MDsgaTw1OyBpKyspIHsJCS8qIDXnp5Hnm67jga7ngrnmlbDlhaXlipvjg6vjg7zjg5cgKi8KICAgIHByaW50ZigiMeenkeebruebruOBruW+l+eCueOCkuWFpeWKm+OBl+OBpuOBj+OBoOOBleOBhOOAgiIpOwogICAgc2NhbmYoIiVkIiwmdG9rdXRlbltpXSk7CiAgICBzdW0rPXRva3V0ZW5baV07CQkvKiDlhajnp5Hnm67jga7ngrnmlbDlkIjoqIjjgavliqDnrpcgKi8KICAgIGlmKHRva3V0ZW5baV0+PTYwKSB7CS8qIOWQiOagvOenkeebruOBi++8nyAqLwogICAgICBjKys7CQkJLyog5ZCI5qC856eR55uu44Gu5pWw44KSKzEgKi8KICAgICAgc3VtX2dva2FrdSs9dG9rdXRlbltpXTsJLyog5ZCI5qC856eR55uu44Gu54K55pWw5ZCI6KiI44Gr5Yqg566XICovCiAgICB9CiAgfQogIGlmKGMpIHsJCQkvKiDlkIjmoLznp5Hnm67jgYzjgYLjgovjgYvvvJ8gKi8KICAgIHByaW50Zigi5ZCI5qC856eR55uu44GvJWTnp5Hnm67jgaflkIjmoLznp5Hnm67jga7lkIjoqIjjga8lZOeCueOBp+OBmVxuIixjLHN1bV9nb2tha3UpOwogICAgYXZnX2dva2FrdT1zdW1fZ29rYWt1LzEuMC9jOyAvKiDlkIjmoLznp5Hnm67jga7lubPlnYfngrnoqIjnrpcgKi8KICAgIHByaW50Zigi5ZCI5qC856eR55uu44Gu5bmz5Z2H44GvJS4xZueCueOBp+OBmVxuIixhdmdfZ29rYWt1KTsKICB9IGVsc2UgewkJCS8qIOWQiOagvOenkeebruOBjOeEoeOBhOWgtOWQiCAqLwogICAgcHJpbnRmKCLlkIjmoLznp5Hnm67jga8lZOenkeebruOBp+WQiOagvOenkeebruOBruWQiOioiOOBryVk54K544Gn44GZXG4iLDAsMCk7CiAgfQogIHByaW50Zigi5YWo56eR55uu44GvJWTnp5Hnm67jgaflkIjmoLznp5Hnm67jga7lkIjoqIjjga8lZOeCueOBp+OBmVxuIiw1LHN1bSk7CiAgYXZnPXN1bS81LjA7CQkJLyog5YWo56eR55uu44Gu5bmz5Z2H54K56KiI566XICovCiAgcHJpbnRmKCLlhajnp5Hnm67jga7lubPlnYfjga8lLjFm54K544Gn44GZXG4iLGF2Zyk7CgogIHJldHVybiAwOwp9