求教大佬,这段代码为什么在codeblocks下宏定义为1时正常运行,不为1时运行停止

#include
#include
#include
#include
#define NO 'F'
#define YES 'P'
#define PASSLINE 320
#define PASSLINE1 75
#define PASSLINE2 45
#define N 1
int npass=0;
struct Stu_Score
{
int number;
char name[20];
double Eng_score;
double mat_score;
double maj_score;
double pol_score;
double sum_score;
char state;
}stu[N];
void Cal_Mark(int i)
{
stu[i].sum_score=stu[i].mat_score+stu[i].Eng_score+
stu[i].pol_score+stu[i].maj_score;
if(stu[i].sum_score>=PASSLINE && stu[i].mat_score>=PASSLINE1 &&
stu[i].maj_score>=PASSLINE1 && stu[i].Eng_score>=PASSLINE2 &&
stu[i].pol_score>=PASSLINE2)
{
stu[i].state=YES;
stu[i].state=YES;
npass++;
}
else
stu[i].state=NO;
}
void exchange(struct Stu_Score *p,struct Stu_Score *q)
{
struct Stu_Score *temp;
temp->number=p->number;
strcpy(temp->name,p->name);
temp->Eng_score=p->Eng_score;
temp->mat_score=p->mat_score;
temp->maj_score=p->maj_score;
temp->pol_score=p->pol_score;
temp->sum_score=p->sum_score;
temp->state=p->state;
mp->state=p->state;
p->number=q->number;
strcpy(p->name,q->name);
p->Eng_score=q->Eng_score;
p->mat_score=q->mat_score;
p->maj_score=q->maj_score;
p->pol_score=q->pol_score;
p->sum_score=q->sum_score;
p->state=q->state;
q->number=temp->number;
strcpy(q->name,temp->name);
q->Eng_score=temp->Eng_score;
q->mat_score=temp->mat_score;
q->maj_score=temp->maj_score;
q->pol_score=temp->pol_score;
q->sum_score=temp->sum_score;
q->state=temp->state;
printf("0000000");
printf("0000000");
}
void SelectionSort(struct Stu_Score stu[])
{
int i,j,k;
for(i=0;i {
k=i;
for(j=i+1;j if(stu[j].sum_score>stu[i].sum_score)
k=j;
if(k!=i)
exchange(&stu[i],&stu[k]);
}
}
int main()
{
int i;
int i;
for(i=0;i<N;i++)
{
system("cls");
printf("请输入NO.%d学生的信息:\n",i+1);
printf("学号:");
scanf("%d",&stu[i].number);
printf("姓名:");
scanf("%s",stu[i].name);
printf("数学成绩:");
scanf("%lf",&stu[i].mat_score);
printf("英语成绩:");
scanf("%lf",&stu[i].Eng_score);
printf("政治成绩:");
scanf("%lf",&stu[i].pol_score);
printf("专业课成绩:");
scanf("%lf",&stu[i].maj_score);
scanf("%lf",&stu[i].maj_score);
}
for(i=0;i<N;i++)
Cal_Mark(i);
SelectionSort(stu);
system("cls");
if(npass)
{
printf("满足要求的学生的复试名单为:\n");
printf("学号\t姓名\t外语\t数学\t政治\t专业课\t总成绩\n");
for(i=0;i<N;i++)
if(stu[i].state==YES)
{
if(stu[i].number/10==0)
printf("00%d\t",stu[i].number);
else if(stu[i].number/100==0)
else if(stu[i].number/100==0)
printf("0%d\t",stu[i].number);
else
printf("%d\t",stu[i].number);
printf("%s\t%g\t%g\t%g\t%g\t%g\n",stu[i].name,
stu[i].Eng_score,stu[i].mat_score,
stu[i].pol_score,stu[i].maj_score,
stu[i].sum_score);
}
}
else
printf("没有满足要求的学生!");
return 0;
}

2个回答

宏定义的N为1时正常运行,不为1时出错显示已停止工作

宏定义的N为1时正常运行,不为1时出错显示已停止工作

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问