【C语言】(数组方式)求n名同学的平均成绩
原理就不说了
代码:
#include <stdio.h> int main() { float score[5], sum = 0; int i; printf("请输入5名童鞋的成绩:\n"); for (i = 0; i < 5; i = i + 1) scanf_s("%f", &score[i]); for (i = 0; i < 5; i = i + 1) sum = sum + score[i]; printf("平均成绩为:%.1f\n", sum / 5); }
本文来自博客园,作者:木子欢儿,转载请注明原文链接:https://www.cnblogs.com/HGNET/p/11919525.html