全部程序在这,运行到蓝色输入只进行一次但,提示三次,红色部分运行直接停止不运行啊WHY???????
#include "stdio.h"
#include "string.h"
struct student
{
int
No;
int Sno;
int total;
int everage;
int English;
int physics;
int maths;
};
struct student stu[30];
struct student stu_1;
int tot(int a,int b,int c)
{
return(a+b+c);
}
int ever(int a)
{
return(a/3);
}
void check(struct student stu[30],int a,int n)
/*查询成绩*/
{
int b,j,i;
while(a==1)
{
printf("your student number:");
scanf("%d",&b);
for(i=0;i<n;i++)
if(stu[i].Sno==b)
{
printf("No.:%d\nSno:%d\ntotal:%f\neverage:%f\nEnglish:%f,physics:%f,maths:%f",stu[i].No,stu[i].Sno,stu[i].total,stu[i].everage,stu[i].English,stu[i].physics,stu[i].maths);
}
printf("\n");
getch();
printf("if you know yourself input 1 else 0 :\n");
scanf("%d",&a);
}
}
main()
{
int n,i,j,min,k;
int a,b,c,d;
int tot(int a,int b,int c);
int ever(int a);
void check(struct student stu[30],int a,int n);
printf("Please input the total students:\n" );
scanf("%d",&n);
/*输入学生人数*/
for(i=1;i<n+1;i++)
{
printf("Please input Sno and
English, Maths ,physicsof score:\n" );
scanf("%d,%d,%d,%d",&k,&b,&c,&d);
stu[k].Sno=k;
stu[k].English=b;
stu[k].physics=c;
stu[k].maths=d;
stu[k].total=tot(b,c,d);
stu[k].everage=ever(stu[k].total);
}
for(i=1;i<n;i++)
{ min=i;
for(j=i+1;j<n+1;j++)
{
if(stu[min].total<stu[j].total)
stu_1=stu[min];
stu[min]=stu[j];
stu[j]=stu_1;
}
}
for(i=1;i<n+1;i++)
stu[i].No=i;
for(i=1;i<n+1;i++)
printf("No.:%3d,Sno:%3d,total:%4f,everage:%4f,English:%4f,physics:%4f,maths:%4f\n",stu[i].No,stu[i].Sno,stu[i].total,stu[i].everage,stu[i].English,stu[i].physics,stu[i].maths);
getch();
printf("if you know yourself input 1 else 0 :\n");
scanf("%d",&a);
check(stu,a,n) ;
getch();
}