C语言程序设计,定义3个函数:input()实现一批成绩的录入?

定义3个函数:input()实现一批成绩的录入,ave()计算一批成绩的平均分,list()按每行5个数据格式显示成绩。主函数调用这些函数数显成绩的录入、计算和显示,
谢谢啦

陪伴而非守候
浏览 1472回答 3
3回答

翻过高山走不出你

#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&nbsp;<stdio.h>&nbsp;int&nbsp;n;float&nbsp;s[100],&nbsp;av,&nbsp;sum&nbsp;=&nbsp;0;&nbsp;void&nbsp;input(){printf("请输入要录入成绩的数目:");scanf("%d",&nbsp;&n);for(int&nbsp;i&nbsp;=&nbsp;0;&nbsp;i&nbsp;<&nbsp;n;&nbsp;i++)scanf("%f",&nbsp;&s[i]);}&nbsp;void&nbsp;avg(){for(int&nbsp;i&nbsp;=&nbsp;0;&nbsp;i&nbsp;<&nbsp;n;&nbsp;i++)sum&nbsp;+=&nbsp;s[i];av&nbsp;=&nbsp;sum&nbsp;/&nbsp;n;}&nbsp;void&nbsp;list(){printf("%5.2f\n",&nbsp;av);&nbsp;}&nbsp;int&nbsp;main()&nbsp;{input();avg();list();return&nbsp;0;}

繁花如伊

定义3个函数:input()实现一批成绩的录入,ave()计算一批成绩的平均分,list()按每行5个数据格式显示成绩。主函数调用这些函数数显成绩的录入、计算和显示,
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Go