C语言编程题

有30个学生,每个学生的数据包括学号、姓名、数学,英语,计算机3门课成绩和总分。要求编写C程序,完成以下任务:。1.从键盘输入30个学生的数据信息,计算每个学生3门课的总... 有30个学生,每个学生的数据包括学号、姓名、数学,英语,计算机3门课成绩和总分。要求编写C程序,完成以下任务:。

1.从键盘输入30个学生的数据信息,计算每个学生3门课的总成绩,并按总

分的高低依次输出每个学生的学号、姓名,3门课成绩及总分。2统计各课最高分和最低分,并输出对应学生的数据信息3.统计各课及格和不及格的人数,输出对应学生的数据信息。
展开
 我来答
Forever_小毅
2019-01-02 · TA获得超过143个赞
知道小有建树答主
回答量:216
采纳率:84%
帮助的人:122万
展开全部

为方便测试,我只写了6个学生的数据,代码里MAX是30,如需要自己测试,要么写30个数据,要么把MAX调小

此处效果图:

此处代码:

#include<stdio.h>

#define MAX 30

struct Student {
char name[100];
char id[100];
int score[4];//Math,English,Computer,Total

void show() {
printf("%s %s %d %d %d %d\n", id, name, score[0], score[1], score[2], score[3]);
}
}stu[MAX], temp;

void sort() {
int i, j;
for (i = 0; i < MAX; i++) {
for (j = i + 1; j < MAX; j++) {
if (stu[i].score[3] < stu[j].score[3]) {
temp = stu[i];
stu[i] = stu[j];
stu[j] = temp;
}
}
}
}

int find(int s) {
int i, max = stu[0].score[s], p = 0;
for(i = 1;i<MAX;++i)
if (stu[i].score[s] > max) {
max = stu[i].score[s];
p = i;
}
return p;
}

int show(int s,int f) {
int i, time = 0;
for (i = 0; i < MAX; i++)
if (stu[i].score[s] > 59 ^ !f) { stu[i].show(); time++; }
return time;
}

int main() {
int i;
for (i = 0; i < MAX; i++) {
scanf("%s %s %d %d %d", stu[i].id, stu[i].name, &stu[i].score[0], &stu[i].score[1], &stu[i].score[2]);
stu[i].score[3] = stu[i].score[0] + stu[i].score[1] + stu[i].score[2];
}
sort();
printf("Rank:\n");
for (i = 0; i < MAX; i++) {
stu[i].show();
}
printf("\n");
char sub[3][10] = { "Math","English","Computer" };
for (i = 0; i < 3; i++) {
printf("%s:\nTotal:\n", sub[i]);
stu[find(i)].show();
printf("Pass:\n");
printf("Sum:%d\n", show(i, 1));
printf("Fail:\n");
printf("Sum:%d\n\n", show(i, 0));
}


}

如无问题麻烦采纳

cahcker
2019-01-02 · TA获得超过1915个赞
知道小有建树答主
回答量:957
采纳率:81%
帮助的人:295万
展开全部
#include<stdio.h>
#define N 30
typedef struct student
{
char ID[10];
char StuName[20];
double MathScore,EnglishScore,Computer;
double TotalScore;
}Student;
void InputScore(Student Info[],int n=N)
{
int i;
char s[2];
for(i=0;i<n;i++)
{
printf("Now Input Infomation:\n");
gets(s);
printf("please input the student's ID:\n");
gets(Info[i].ID);
printf("please input the student's Name:\n");
gets(Info[i].StuName);
while(1)
{ printf("please enter the MathScore:\n");
scanf("%lf",&Info[i].MathScore);
if(Info[i].MathScore>=0 &&Info[i].MathScore<=100)
break;
else
printf("The score must be 0~100:\n");

}

while(1)
{ printf("please enter the EnglishScore:\n");
scanf("%lf",&Info[i].EnglishScore);
if(Info[i].EnglishScore>=0 &&Info[i].EnglishScore<=100)
break;
else
printf("The score must be 0~100:\n");

}

while(1)
{ printf("please enter the ITScore:\n");
scanf("%lf",&Info[i].Computer);
if(Info[i].Computer>=0 &&Info[i].Computer<=100)
break;
else
printf("The score must be 0~100:\n");

}
Info[i].TotalScore=Info[i].MathScore+Info[i].EnglishScore+Info[i].Computer;
}
printf("The infomation is completed!\n");
}
void sort(Student Info[],int n=N)
{
int i,j;
Student Temp;
for(i=0;i<n;i++)
{
for(j=0;j<i;j++)
if(Info[i].TotalScore>Info[j].TotalScore)
{
Temp=Info[i];
Info[i]=Info[j];
Info[j]=Temp;

}

}
printf("The sort by total score:\n");
for(i=0;i<n;i++)
{
printf("No.:%d",i+1);
printf("Student's ID:%s\n",Info[i].ID);
printf("Student's Name:%s\n",Info[i].StuName);
printf("The Score of 3 class,Math:%lf,English:%lf,IT:%lf",Info[i].MathScore,Info[i].EnglishScore,Info[i].Computer);
printf("\n\n");
}
}
void showrange(Student Info[],int C,int n=N)
{
int i;
Student TempMax,TempMin;
if(C==1)
{
TempMax=TempMin=Info[0];
for(i=0;i<n;i++)
{
if(Info[i].MathScore>TempMax.MathScore)
TempMax=Info[i];
if(Info[i].MathScore<TempMax.MathScore)
TempMin=Info[i];
}
printf("The Highest Math Score and The Lowest Math score:\n");
}
else if(C==2)
{
TempMax=TempMin=Info[0];
for(i=0;i<n;i++)
{
if(Info[i].EnglishScore>TempMax.EnglishScore)
TempMax=Info[i];
if(Info[i].EnglishScore<TempMax.EnglishScore)
TempMin=Info[i];
}
printf("The Highest English Score and The Lowest English score:\n");

}
else
{
TempMax=TempMin=Info[0];
for(i=0;i<n;i++)
{
if(Info[i].Computer>TempMax.Computer)
TempMax=Info[i];
if(Info[i].Computer<TempMax.Computer)
TempMin=Info[i];
}
printf("The Highest IT Score and The Lowest IT score:\n");
}
printf("Higest:\n");
printf("Student's ID:%s\n",TempMax.ID);
printf("Student's Name:%s\n",TempMax.StuName);
printf("The Score of 3 class,Math:%lf,English:%lf,IT:%lf",TempMax.MathScore,TempMax.EnglishScore,TempMax.Computer);
printf("\n\n");
printf("HLowest:\n");
printf("Student's ID:%s\n",TempMin.ID);
printf("Student's Name:%s\n",TempMin.StuName);
printf("The Score of 3 class,Math:%lf,English:%lf,IT:%lf",TempMin.MathScore,TempMin.EnglishScore,TempMin.Computer);
}
void showgade(Student Info[],int C,int n=N)
{
int i;
if(C==1)
{
printf("Statis for Math Over 60:\n");
for(i=0;i<n;i++)
if(Info[i].MathScore>=60)
{
printf("Student's ID:%s\nStudent's Name %s\n",Info[i].ID,Info[i].StuName);
printf("Score Math:%lf,English:%lf,IT:%lf",Info[i].MathScore,Info[i].EnglishScore,Info[i].Computer);
printf("\n\n");

}
printf("Statis for Math Under 60:\n");
for(i=0;i<n;i++)
if(Info[i].MathScore<60)
{
printf("Student's ID:%s\nStudent's Name %s\n",Info[i].ID,Info[i].StuName);
printf("Score Math:%lf,English:%lf,IT:%lf",Info[i].MathScore,Info[i].EnglishScore,Info[i].Computer);
printf("\n\n");

}
}
else if(C==2)
{
printf("Statis for English Over 60:\n");
for(i=0;i<n;i++)
if(Info[i].EnglishScore>=60)
{
printf("Student's ID: %s\nStudent's Name: %s\n",Info[i].ID,Info[i].StuName);
printf("Score Math:%lf,English:%lf,IT:%lf",Info[i].MathScore,Info[i].EnglishScore,Info[i].Computer);
printf("\n\n");

}
printf("Statis for English Under 60:\n");
for(i=0;i<n;i++)
if(Info[i].EnglishScore<60)
{
printf("Student's ID:%s\nStudent's Name %s\n",Info[i].ID,Info[i].StuName);
printf("Score Math:%lf,English:%lf,IT:%lf",Info[i].MathScore,Info[i].EnglishScore,Info[i].Computer);
printf("\n\n");

}
}
else
{
printf("Statis for IT Over 60:\n");
for(i=0;i<n;i++)
if(Info[i].Computer>=60)
{
printf("Student's ID:%s\nStudent's Name %s\n",Info[i].ID,Info[i].StuName);
printf("Score Math:%lf,English:%lf,IT:%lf",Info[i].MathScore,Info[i].EnglishScore,Info[i].Computer);
printf("\n\n");

}
printf("Statis for IT Under 60:\n");
for(i=0;i<n;i++)
if(Info[i].Computer<60)
{
printf("Student's ID:%s\nStudent's Name %s\n",Info[i].ID,Info[i].StuName);
printf("Score Math:%lf,English:%lf,IT:%lf",Info[i].MathScore,Info[i].EnglishScore,Info[i].Computer);
printf("\n\n");

}
}
}
int main()
{
Student INF[N];
int a;
InputScore(INF,N);
printf("Now sort for total score:\n");
sort(INF,N);
printf("Show the Higest and Lowest of Math, please Enter 1:\n");
printf("Show the Higest and Lowest of English, please Enter 2:\n");
printf("Show the Higest and Lowest of IT, please Enter 3:\n");
while(1)
{
scanf("%d",&a);
if(a>=1&&a<=3) break;
else
printf("Your Option is not correct");
}
showrange(INF,a,N);
printf("Show the score of Math,Enter 1:\n");
printf("Show the score of English,Enter 2:\n");
printf("Show the score of IT,Enter 3:\n");
while(1)
{
scanf("%d",&a);
if(a>=1&&a<=3) break;
else
printf("Your Option is not correct");
}
showgade(INF,a,N);
}
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
mqcake
2019-01-02 · TA获得超过218个赞
知道小有建树答主
回答量:694
采纳率:0%
帮助的人:230万
展开全部
为什么这段时间这么多学生管理系统。
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 1条折叠回答
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式