【高价悬赏】我电脑没有环境和软件,就发到这里了。
题目要求:
编写一个C语言程序,输入10名同学的8门课成绩,分别统计出每个同学的总成绩与平均成绩及10名同学每门课的平均成绩。并按表格的形式输出。(表格形式为:一共12行11列,第一行为表头,10列依次显示姓名、8门课的课程名称、总分、平均分;从第二行开始为具体内容,依次显示10名同学的名字及其8门课成绩及总分和平均分,第十二行只显示9列,分别显示平均分及8门课的平均分分值。)
本来这种作业题,我是不会在csdn回答,不过既然有人瞎说八道,我就纠正一下吧:
#include<stdio.h>
#define N 10
struct student
{
int num; //学生学号
char name[10]; //学生姓名
float course[8]; //8门课程成绩
float total; //总分
float avg; //平均分
}st[N]; //定义结构体数组
int main()
{
int i,j;
int sum = 0;
float average[9] = {0};
system("mode con cols=120 lines=40");
for (i = 0; i < N; i++)
{
printf("请输入学生学号:");
scanf("%d", &st[i].num);
printf("请输入学生姓名:");
scanf("%s", st[i].name);
printf("请输入学生8门成绩:\n");
st[i].total = 0;
for (j = 0; j < 8;j++)
{
scanf("%f", &st[i].course[j]);
average[j] += st[i].course[j];//每门课累加值
st[i].total += st[i].course[j]; //统计学生的总分
}
average[8] += st[i].total;
st[i].avg = st[i].total / 8;//学生平均分
}
for (j = 0; j < 9; j++)
{
average[j] = average[j] / N;
}
printf("学号 姓名 课程1 课程2 课程3 课程4 课程5 课程6 课程7 课程8 总分 平均分\n");
for (i = 0; i < N; i++)
{
printf("%-7d %-7s %-7.0f %-7.0f %-7.0f %-7.0f %-7.0f %-7.0f %-7.0f %-7.0f %-7.0f %-7.2f\n",
st[i].num, st[i].name, st[i].course[0], st[i].course[1], st[i].course[2],
st[i].course[3], st[i].course[4], st[i].course[5], st[i].course[6], st[i].course[7], st[i].total, st[i].avg);
}
printf("平均 ");
for (j = 0; j < 9; j++) printf("%-8.2f", average[j]);
printf("\n");
return 0;
}
https://blog.csdn.net/return9/article/details/53302300
#include<stdio.h>
#define N 50
struct student
{
int num;
char name[10]; //学生姓名
int course1; // 课程1的分数
int course2; //课程2的分数
int course3; //课程3的分数
int total; //总分
}; //定义结构体
void main()
{
struct student st[N]; //声明结构体数组
int i,max,maxi; //maxi用来记录3门课成绩最高的学生在数组中的位置
float average1 = 0, average2 = 0, average3 = 0;
for(i = 0; i < N; i++)
{
scanf("%d",&st[i].num);
scanf("%d",&st[i].course1);
average1 = average1 + st[i].course1; //统计课程1的总分
scanf("%d",&st[i].course2);
average2 = average2 + st[i].course2; //统计课程2的总分
scanf("%d",&st[i].course3);
average3 = average3 + st[i].course3; //统计课程3的总分
scanf("%s",st[i].name);
st[i].total = st[i].course1 + st[i].course2 + st[i].course3;
}
average1 = average1 / N;
average2 = average2 / N;
average3 = average3 / N;
max = st[0].total;
for(i = 1; i < N; i++)
if(st[i].total >= max)
{
max = st[i].total;
maxi = i;
}
printf("三门课的平均成绩:\n");
printf("%.2f %.2f %.2f\n",average1,average2,average3);
printf("总分最高的学生:\n");
printf("学号 姓名 课程1 课程2 课程3 总分\n");
printf("%d %s %d %d %d %d\n" , st[maxi].num , st[maxi].name , st[maxi].course1 , st[maxi].course2 , st[maxi].course3 , st[maxi].total);
}
```C