这是我写的,不过还有错误,不能编译通过。我刚学,很多都不会,希望大家多多指教!
/* student_score.c */
#define max 100
#include "stdio.h"
#include "conio.h"
struct date
{
float chinese;
float math;
float english;
float computer;
float summary;
float average;
}
struct student
{
int number;
char name[20];
char sex;
struct date score;
}student[max],*point;
print_information(int i)
{
printf("%d %c %s:\nchinese:%f english:%f computer:%f summary:%f average:%f\n",student[i].number,student[i].sex,student[i].name,student[i].score.chinese,student[i].score.math,student[i].score.english,student[i].score.computer,student[i].score.summary,student[i].score.average);
}
scanf_information(int i)
{
printf("please input the student's number:");
scanf("%d",&student[i].number);
printf("\nplease input the student's sex:");
scanf("%c",&student[i].sex);
printf("\nplease input the student's name:");
scanf("%s",student[i].name);
printf("\nplease input the score of chinese,math,english and computer:");
scanf("%f,%f,%f",&student[i].score.chinese,&student[i].score.math,&student[i].score.english,&student[i].score.computer);
student[i].score.summary=student[i].score.chinese+student[i].score.math+student[i].score.english+student[i].score.computer;
student[i].sco e.average=student[i].score.summary/4.0;
}
void bubblesort(int *point,int index)
{
int i,j;
int temp;
int change;
while(!change)
{
change=1;
for(j=index;j>0;j--)
for(i=0;i<j-1;i++)
if(point[i]>point[i+1])
{temp=point[i+1];
point[i+1]=point[i];
point[i]=temp;
change=0;
}
}
}
main()
{
int biaohao;
int i,selection;
int counter;
printf("please input the number of student:");
scanf("%d",&count);
if(count>=100)
printf("please input a number less than 100");
else
{
printf("please input the student's information:\n");
for(i=0;i<counter;i+=)
scanf_information(i);
bubblesort(student *point,count);
printf("\nfinal sorting result:");
for(i=0;i<counter;i++)
print_information(i);
printf("if you choose 1.Display student information\n");
printf("if you choose 2.Modify student information\n");
printf("if you choose 3 will quit\n");
printf("please input your choose:");
scanf("%d",&selection);
if(selection==1||selection==2)
{
printf("please input the student number:");
scanf("%d",&biaohao);
if(biaohao<100)
printf_information(biaohao);
else
{printf("the error student number!:");
printf("please input again\n");
}
}
swith(selection)
{case 1:break;
case 2:printf("please input the student's information:\n");
scanf_information(bianhao);
student[counter].score.chinese=student[biaohao].score.chinese;
student[counter].score.math=student[biaohao].score.math;
student[counter].score.english=student[biaohao].score.english;
student[counter].score.computer=student[biaohao].score.computer;
student[counter].score.summary=student[biaohao].score.summary;
student[counter].score.average=student[biaohao].score.average;
break;
case 3:break;
}
}
}