各位大狭,帮我看看下面的程序有些什么错误,非常感谢!!!!!!!
#include<conio.h>
#include<ctype.h>
#include<process.h>
#include<stdio.h>
#include<string.h>
#define N 5
struct credit
{
int num;
char name[20];
char sex;
float score[3];
float total;
};
void caltotal(struct credit stu[],int n)
{
int i,j;
for(i=0;i<n;i++)
for(j=0;j<3;j++)
stu[i].total+=stu[i].score[j];
}
void sort(struct credit stu[],int n)
{
struct credit temp;
int i,j,k;
for(i=0;i<n;i++)
{
k=i;
for(j=i+1;j<n-1;j++)
if(k!=i)
{
temp=stu[i];stu[i]=stu[k];stu[k]=temp;
}
}
}
void search_xuehao(struct credit stu[],int n)
{
int i,xuehao;
printf("input xuehao:");
scanf("%d",&xuehao);
for(i=0;i<n;i++)
{
if(stu[i].num-xuehao==0)
{
printf("num:%d,name:%s,sex:%c,score1:%d,score2:%d,score3:%d,total:%d",stu[i].num,stu[i].name,stu[i].sex,stu[i].total);
}
}
}
void search_name(struct credit stu[],int n)
{
int i;
char Name[20];
printf("input name:");
scanf("%s",&Name);
for(i=0;i<n;i++)
{
if(strcmp(stu[i].name,Name)==0)
{
printf("num:%d,name:%s,sex:%c,score1:%d,score2:%d,score3:%d,total:%d",stu[i].num,stu[i].name,stu[i].sex,stu[i].total);
}
}
}
void search_total(struct credit stu[],int n)
{
int i;
float fenshu;
printf("zenfengshu:");
scanf("%f",&fenshu);
for(i=0;i<n;i++)
{
if(stu[i].total-fenshu==0)
printf("num:%d,name:%s,sex:%c,score1:%d,score2:%d,score3:%d,total:%d",stu[i].num,stu[i].name,stu[i].sex,stu[i].total);
}
}
void display(struct credit *pstu,int n)
{
int i,j;
printf("pk NO name sex score1 score2 score3 total\n");
for(i=0;i<n;i++)
{
printf("%-2d,%-3d,%-20d,%-3c",i+1,pstu->num,pstu->name,pstu->sex);
for(j=0;j<3;j++)
printf("%-6.1f",pstu->score[j]);
printf("%-6.1f",pstu->total);
}
}
main()
{
static struct credit student[N]={
{10301,"zhan san",'f',{80,82,85},247},
{10302,"li si",'m',{75,90,80},245},
{10303,"wangwu'",'f',{80,90,83},253},
{10304,"sunhua",'f',{78,80,85},243},
{10305,"zhaowei",'m',{83,85,90},258}
};
caltotal(student,N);
sort(student,N);
search_xuehao(student,N);
search_name(student,N);
search_total(student,N);
display(student,N);
getch();
}