c语言实训题跪求每部的详细解释,哪位会的好心人告告呗,由于题太长分俩个提问,把俩都答了呗,先谢了 10

voidpaixu(intstu[STU][COU],charstudent[10][100],intt){inti,j,k,temp;charCourse_name[1... void paixu(int stu[STU][COU],char student[10][100],int t)
{
int i,j,k,temp;
char Course_name[10];char studentx[100];
printf("\nEnter the original Course Results of the %d student:",STU);
printf("\n");
printf(" ");
for(k=0;k<COU;k++)
{
getstr(Course_name,k+1);
printf("%s ",Course_name);
}
printf("\n");
for(i=0;i<STU;i++)
{
printf("the %dth student:%s ",i+1,student[i]);
for(j=0;j<COU;j++)
printf(" %d ",stu[i][j]);
printf("\n");
}
for(i=1;i<=STU-1;i++)
for(j=0;j<=STU-i-1;j++)
if(stu[j][t]<stu[j+1][t])
for(k=0;k<COU;k++)
{temp=stu[j][k];stu[j][k]=stu[j+1][k];stu[j+1][k]=temp;
strcpy(studentx,student[j]);strcpy(student[j],student[j+1]);strcpy(student[j+1],studentx);
}
printf("\nEnter the paixu Course Results of the %d student :",STU);
printf("\n");
printf(" ");
for(k=0;k<COU;k++)
{
getstr(Course_name,k+1);
printf("%s ",Course_name);
}
printf("\n");
for(i=0;i<STU;i++)
{
printf("the %dth student:%s ",i+1,student[i]);
for(j=0;j<COU;j++)
printf(" %d ",stu[i][j]);
printf("\n");
}
}
main()
{
int stu[10][5]={0};int m;
float ave5[5]={0.0},ave10[10]={0.0},var10[10]={0.0};
char student[10][100]={""};
while(1)
{
switch(menu())
{
case 1:
enter_stu(stu,student);break;
case 2:
stu_ave5(ave5,stu);printf("\n");break;
case 3:
stu_ave10(ave10,stu,student);printf("\n");break;
case 4:
find_max(stu,student);printf("\n");break;
case 5:
printf("please enter a number between 0_4:");scanf("%d",&m);
paixu(stu,student,m);printf("\n");break;
case 6:
exit(0);
}
}
}
展开
 我来答
有钱买不起房子
2011-06-30 · TA获得超过4326个赞
知道大有可为答主
回答量:1249
采纳率:100%
帮助的人:2093万
展开全部
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define STU 2
#define COU 4

//根据编号复制字符串
void getstr(char*s,int index)
{
switch(index)
{
case 1:
strcpy(s,"YuWen");break;
case 2:
strcpy(s,"YingYu");break;
case 3:
strcpy(s,"ShuXue");break;
case 4:
strcpy(s,"TiYu");break;
case 5:
strcpy(s,"JiSuanJi");break;
}
}

//菜单显示
int menu()
{
int choice=0;
printf("\n***********************************************\n");
printf("* Student Course Management System *\n\n");
printf("* 1.Enter student Course Results *\n\n");
printf("* 2.Calculat student %d Course Average Results *\n\n",COU);
printf("* 3.Calculat %d student Average Results *\n\n",STU);
printf("* 4.Find Max Course Result student *\n\n");
printf("* 5.paixu %d student base on one course *\n\n",STU);
printf("* 6.Exit *");
printf("\n***********************************************\n");
do{
printf(" Enter choice:");
scanf("%d",&choice);
}while(choice<1||choice>6);//1到6选择不同菜单
return choice;
}

//录入课程分数
void enter_stu(int stu[STU][COU],char student[10][100])
{
int i,j;
char Course_name[10];
for(i=0;i<STU;i++)//逐个遍历学生
{
printf("\nEnter%dth student Course Results:the name of the student is:",i+1);
scanf("%s",student[i]);
for(j=0;j<COU;j++)//录入每个学生课程分数
{
getstr(Course_name,j+1);
printf("\n%s:",Course_name);
scanf("%d",&stu[i][j]);
}
}
}

//统计每个课程的平均分
void stu_ave5(float ave5[COU],int stu[STU][COU])
{
int i,j;
char Course_name[10];
float ave;
for(i=0;i<COU;i++)//逐个遍历课程
{
ave=0.0;
getstr(Course_name,i+1);
printf("\n%dth Course %s Average is ",i+1,Course_name);
for(j=0;j<STU;j++)//累加所有学生当前课程分数
ave+=stu[j][i];
ave5[i]=ave/STU;//计算当前课程平均分
printf("%0.2f.\n",ave5[i]);
}
}

//计算每个学生各科平均分
void stu_ave10(float ave10[STU],int stu[STU][COU],char student[10][100])
{
int i,j;
float ave;
for(i=0;i<STU;i++)//逐个遍历学生
{
ave=0.0;
printf("\n%dth student %s %d Course Average is",i+1,student[i],COU);
for(j=0;j<COU;j++)//累加当前学生所有课程分数
ave+=stu[i][j];
ave/=COU;//计算各科平均分
ave10[i]=ave;
printf("%0.2f.\n",ave10[i]);
}
}

//查找最高课程分数对应的学生和课程名称
void find_max(int stu[STU][COU],char student[10][100])
{
int i,j,max=0,max_i=0,max_j=0;
char Course_name[10];
for(i=0;i<STU;i++)//逐个遍历学生
{
for(j=0;j<COU;j++)//逐个遍历当前学生的各门课程
{
if(stu[i][j]>max)//如果分数高于最大值,进行交换
{
max=stu[i][j];
max_i=i;
max_j=j;
}
}
}
printf("\nThe %dth student %s have Max Course Result:",max_i+1,student[max_i]);
getstr(Course_name,max_j+1);
printf("\n%s:%d.",Course_name,stu[max_i][max_j]);
}

//
void paixu(int stu[STU][COU],char student[10][100],int t)
{
int i,j,k,temp;
char Course_name[10];char studentx[100];
printf("\nEnter the original Course Results of the %d student:",STU);
printf("\n");
printf(" ");
for(k=0;k<COU;k++)//显示课程名称
{
getstr(Course_name,k+1);
printf("%s ",Course_name);
}
printf("\n");
for(i=0;i<STU;i++)//显示每个学生各门课程分数
{
printf("the %dth student:%s ",i+1,student[i]);
for(j=0;j<COU;j++)
printf(" %d ",stu[i][j]);
printf("\n");
}
for(i=1;i<=STU-1;i++)//冒泡排序,按每个学生的某门课程进行降序
for(j=0;j<=STU-i-1;j++)
if(stu[j][t]<stu[j+1][t])
for(k=0;k<COU;k++)
{temp=stu[j][k];stu[j][k]=stu[j+1][k];stu[j+1][k]=temp;
strcpy(studentx,student[j]);strcpy(student[j],student[j+1]);strcpy(student[j+1],studentx);
}
printf("\nEnter the paixu Course Results of the %d student :",STU);
printf("\n");
printf(" ");
for(k=0;k<COU;k++)
{
getstr(Course_name,k+1);
printf("%s ",Course_name);
}
printf("\n");
for(i=0;i<STU;i++)
{
printf("the %dth student:%s ",i+1,student[i]);
for(j=0;j<COU;j++)
printf(" %d ",stu[i][j]);
printf("\n");
}
}

main()
{
//定义变量
int stu[10][5]={0};int m;
float ave5[5]={0.0},ave10[10]={0.0},var10[10]={0.0};
char student[10][100]={""};
while(1)//循环菜单,选择不同功能
{
switch(menu())
{
case 1:
enter_stu(stu,student);break;
case 2:
stu_ave5(ave5,stu);printf("\n");break;
case 3:
stu_ave10(ave10,stu,student);printf("\n");break;
case 4:
find_max(stu,student);printf("\n");break;
case 5:
printf("please enter a number between 0_4:");scanf("%d",&m);
paixu(stu,student,m);printf("\n");break;
case 6:
exit(0);
}
}
}
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

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

类别

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

说明

0/200

提交
取消

辅 助

模 式