-
翻过高山走不出你
#include <stdio.h>int n;float s[100], av, sum = 0;void input(){printf("请输入要录入成绩的数目:");scanf("%d", &n);for(int i = 0; i < n; i++)scanf("%f", &s[i]);}void avg(){for(int i = 0; i < n; i++)sum += s[i];av = sum / n;}void list(){printf("%5.2f\n", av);}int main(){input();avg();list();return 0;}因为你的要求有些细节说的不是太清楚,初步就这么写了,有改动可以告诉我~
-
交互式爱情
依次输入成绩:1234567891011121314151617181920212223242526272829303132#include <stdio.h> int n;float s[100], av, sum = 0; void input(){printf("请输入要录入成绩的数目:");scanf("%d", &n);for(int i = 0; i < n; i++)scanf("%f", &s[i]);} void avg(){for(int i = 0; i < n; i++)sum += s[i];av = sum / n;} void list(){printf("%5.2f\n", av); } int main() {input();avg();list();return 0;}
-
繁花如伊
定义3个函数:input()实现一批成绩的录入,ave()计算一批成绩的平均分,list()按每行5个数据格式显示成绩。主函数调用这些函数数显成绩的录入、计算和显示,