㈠ C语言:5个人3门课,求输出总成绩,平均成绩
设5个人3门课,求输出总成绩与平均成绩#include <stdio.h> int main(){ float score = 0.0; float score_total = 0.0; float score_average = 0.0; int n1; int n2; for(n1=0;n1<5;n1++) { for(n2=0;n2<3;n2++) { printf("请输入第%d个人的第%d门成绩:", n1, n2); scanf("%f", &score); score_total = score_total + score; } } score_average = score_total/15; printf("总成绩=%f,平均成绩=%f\n", score_total, score_average); return 0;}
㈡ 有5人3门课成绩 编程求各科的平均分和总平均成绩 谢谢 用数组 简单的c语言程序
#include<stdio.h>
main()
{
inti,t=0,s=0,j,a[5][3]={{33,22,44},{22,44,55},{22,44,77},{99,33,44},{99,33,44}};
for(j=0;j<3;j++)
{
for(i=0;i<5;i++)
{
s=s+a[i][j];
t=s+t;
}
printf("%d ",s);
s=0;
}
printf("%d ",t/15);
}
㈢ C语言程序设计题:5个学生,姓名,学号,3门成绩,要求平均成绩,输出一张成绩表
#include <stdio.h> void main() { int i,j; float a[3][3]; printf("请输入3个同学3门课的成绩:\n"); for(i=0;i<3;i++) { for(j=0;j<3;j++) scanf("%f",&a[i][j]); } printf("=================================================\n"); for(i=0;i<3;i++) { printf(" | "); for(j=0;j<3;j++) { printf(" %4.1f |",a[i][j]); } printf("\n"); printf("------------------------------------------\n"); } printf("=================================================\n"); getchar(); }
㈣ C语言编程:输入5名学生3门课程成绩
楼上说的是...还有:
stdsco 没有赋初值诶...
所以系统给了一个很小的值,你在 stdsco += sco;
这里实际上没多大用...那个值太小了...
建议啦:以后在新建变量的时候就给他一个初值...