以c语言按系列要求写程序,要求:输入6个学生的三门课程的成绩,统计每个学生的总成绩,并输出总分最高的那个学生的3门课程的成绩和总分
时间: 2023-06-02 22:07:20 浏览: 58
好的,这是一个关于编程的问题,我可以回答。以下是程序的代码:
```
#include<stdio.h>
int main()
{
int scores[6][3];
int total[6];
int i, j, max, max_index;
printf("请输入6个学生的三门课程的成绩:\n");
for(i=0; i<6; i++)
{
printf("请输入第%d个学生的成绩:\n",i+1);
for(j=0; j<3; j++)
{
scanf("%d", &scores[i][j]);
}
total[i] = scores[i][0] + scores[i][1] + scores[i][2];
}
max = total[0];
max_index = 0;
for(i=1; i<6; i++)
{
if(total[i] > max)
{
max = total[i];
max_index = i;
}
}
printf("总分最高的学生是第%d个学生,总成绩为%d,三门课程的成绩为:\n", max_index+1, max);
for(j=0; j<3; j++)
{
printf("%d ", scores[max_index][j]);
}
return 0;
}
```
希望能帮到您。
相关问题
用c语言编写:输入五个学生的三门课程成绩,求每个学生的平均成绩和每门课程的平均成绩
以下是一个用C语言编写的程序,可以实现输入五个学生的三门课程成绩,求每个学生的平均成绩和每门课程的平均成绩。这里假设每门课程的成绩都是一个整数。
```c
#include <stdio.h>
int main() {
int scores[5][3];
int i, j;
int student_sum[5] = {0};
int course_sum[3] = {0};
// 输入每个学生的三门课程成绩
for (i = 0; i < 5; i++) {
printf("请输入第%d个学生的三门课程成绩:\n", i+1);
for (j = 0; j < 3; j++) {
scanf("%d", &scores[i][j]);
student_sum[i] += scores[i][j];
course_sum[j] += scores[i][j];
}
}
// 输出每个学生的平均成绩
printf("每个学生的平均成绩:\n");
for (i = 0; i < 5; i++) {
printf("第%d个学生的平均成绩为:%.2f\n", i+1, (float)student_sum[i]/3);
}
// 输出每门课程的平均成绩
printf("每门课程的平均成绩:\n");
for (j = 0; j < 3; j++) {
printf("第%d门课程的平均成绩为:%.2f\n", j+1, (float)course_sum[j]/5);
}
return 0;
}
```
该程序首先定义了一个二维数组`scores`来存储每个学生的三门课程成绩,以及两个一维数组`student_sum`和`course_sum`,分别用于存储每个学生的总成绩和每门课程的总成绩。程序使用嵌套的循环来依次输入每个学生的三门课程成绩,并且累加每个学生的总成绩和每门课程的总成绩。最后,程序根据累加的数据计算并输出每个学生的平均成绩和每门课程的平均成绩。
c语言输入6个学生、3门课程的成绩,统计每个学生的总成绩,并输出总分最高的那位学生的3门课程的成绩和总分。
好的,这是一个关于C语言编程的问题,我可以给你提供答案。可以使用一个二维数组来存储学生的成绩,然后使用循环和条件语句来计算总成绩和输出最高总分的学生的成绩。以下是一个简单的示例代码:
```c
#include <stdio.h>
int main() {
int scores[6][3];
int i, j, total, max = 0, max_index;
// 输入学生成绩
for (i = 0; i < 6; i++) {
printf("请输入第%d个学生的三门课程成绩:\n", i + 1);
for (j = 0; j < 3; j++) {
scanf("%d", &scores[i][j]);
}
}
// 计算每个学生的总成绩,找出总分最高的学生
for (i = 0; i < 6; i++) {
total = 0;
for (j = 0; j < 3; j++) {
total += scores[i][j];
}
if (total > max) {
max = total;
max_index = i;
}
}
// 输出总分最高的学生的成绩
printf("总分最高的是第%d个学生,成绩如下:\n", max_index+1);
for (j = 0; j < 3; j++) {
printf("%d ", scores[max_index][j]);
}
printf("总成绩为%d\n", max);
return 0;
}
```
希望这个代码可以帮到你。如果有其他问题,欢迎继续提问。