求高手调试,找找有什么问题!
/* HELLO.C -- Hello, world */#include "stdio.h"
#include "conio.h"
#include "math.h"
struct a
{
int xh;
char xm[10];
int qz;
int qm;
int zp;
};
/*定义数组*/
int add(struct a z[50],int i)
{
int a,b;
printf("add number\n");
scanf("%d",&a);
for(b=1;b<=a;b++)
{printf("xh xm qz qm \n");
scanf("%d %s %d %d",&z[b].xh,&z[b].xm,&z[b].qz,&z[b].qm);
z[b].zp=z[b].qz+z[b].qm;
}
i=i+1;
return i;
}
/*添加记录*/
int delete(struct a z[50],int i)
{
int j,k,l;
printf("delete xh");
scanf("%d",&k);
for(j=0;j<=i;j++)
if(k==z[j].xh)
l=j;
for(;l<=i;l++)
z[l]=z[l+1];
i--;
return i;
}
/*删除记录*/
void sort(struct a z[50],int i)
{
int j,k;
struct a a;
for(j=0;j<i;j++)
for(k=j+1;k<=i;k++)
if(z[j].zp>z[k].zp)
{
a=z[j];
z[j]=z[k];
z[k]=a;
}
}
/*记录排序*/
int top(struct a z[50],int i)
{
int j,k,max=0;
for(j=0;j<=i;j++)
if(z[j].zp>max)
max=z[j].zp;
printf("the top is %d",max);
}
/*最高分*/
int low(struct a z[50],int i)
{
int j,k,min;
for(j=0;j<=i;j++)
if(z[j].zp<z[j+1].zp)
min=z[j].zp;
else
min=z[j+1].zp;
printf("the low is %d",min);
}
/*最低分*/
int ave(struct a z[50],int i)
{ int j,s=0;
for(j=0;j<=i;j++)
{
s=s+z[j].zp;
}
printf("the average is%d",s/i);
}
/*平均分*/
void pass(struct a z[50],int i)
{
int j,k;
for(j=0;j<=i;j++)
{
if(z[j].zp>=60)
k++;
}
return k;
}
/*及格率*/
void name(struct a z[50],int i)
{ int j,k;
printf("please input name:");
scanf("%s",&k);
for(j=0;j<=i;j++)
{
if(z[j].xm==k)
printf("%d %s %d %d %d",z[j].xh,z[j].xm,z[j].qz,z[j].qm,
z[j].zp=z[j].qz*0.3+z[j].qm*0.7);
else
printf("error!") ;
}
}
/*按姓名查询*/
void number(struct a z[50],int i)
{ int j,k;
printf("please input number:");
scanf("%d",&k);
for(j=0;j<=i;j++)
{
if(z[j].xh==k)
printf("%d %s %d %d %d",z[j].xh,z[j].xm,z[j].qz,z[j].qm,
z[j].zp=z[j].qz*0.3+z[j].qm*0.7);
else
printf("error!") ;
}
}
/*按学号查询*/
main()
{ struct a z[50];
int a,b,i;
char c,w;
printf("********************************************************************************");
printf("\n");
printf(" 1.Grade Management ");
printf("\n");
printf(" 2.Results Summary ");
printf("\n");
printf(" 3.Search Results ");
printf("********************************************************************************");
printf("\n\n");
printf(" qing xuan ze:");
printf("\n\n\n");
printf("qing xuan ze : ");
scanf("%d",&a);
if(a==1)
{ clrscr();
printf(" ****************************\n\n");
printf("*************************** 1.Grade Management ***************************\n");
printf(" ****************************\n\n");
printf("\n\n\n\n");
printf("%s\n\n\n"," 1. Add stu_info");
printf("%s\n\n\n"," 2. Delete stu_info");
printf("%s\n\n\n"," 3. Sort stu_info");
printf("%s\n\n\n"," 4. return");
printf("qing xuan ze : ");
getchar();
scanf("%c",&b);
if(b==1)
i=add(&z,i);
if(b==2)
i=delete(&z,i);
if(b==3)
sort(&z,i);
getchar();
}
if(a==2)
{ clrscr();
printf(" ****************************\n\n");
printf("*************************** 2.Results Summary ***************************\n");
printf(" ****************************\n\n");
printf("\n\n\n\n");
printf("%s\n\n\n"," 1. Check top grade");
printf("%s\n\n\n"," 2. Check low grade");
printf("%s\n\n\n"," 3. Check all the average grade");
printf("%s\n\n\n"," 4. Check the pass grade");
printf("%s\n\n\n"," 5. return");
printf("qing xuan ze : ");
getchar();
scanf("%c",&b);
if(b==1)
i=top(&z,i);
if(b==2)
i=low(&z,i);
if(b==3)
i=ave(&z,i);
if(b==4)
pass(&z,i);
getchar();
}
if(a==3)
{ clrscr();
printf(" ****************************\n\n");
printf("*************************** 3.Search Results ***************************\n");
printf(" ****************************\n\n");
printf("\n\n\n\n");
printf("%s\n\n\n"," 1. Check the grade by name");
printf("%s\n\n\n"," 2. Check the grade by number");
printf("%s\n\n\n"," 3. return");
printf("qing xuan ze : ");
getchar();
scanf("%c",&b);
if(b==1)
name(&z,i);
if(b==2)
number(&z,i);
getchar();
}
}