镇魂街真人版许褚图片:请高手帮我看看这段代码

来源:百度文库 编辑:神马品牌网 时间:2024/05/09 03:28:34
请看看为什么程序为什么执行到循环部分就出错了
#include <stdio.h>
#include <stdlib.h>
#include "type.h"
#include "sub_fun.h"
extern int total;
student* creat(int n,student *head)//开辟新的结点
{
student *p1,*p2;
int sum,i;
char out;
sum=total;
if(n==0)
{
printf("录入结束\n");
return(head);
}
else
{
p1=p2=(student *)malloc(LEN1);
printf("请输入第%d个学生的学号:",total+1);
gets(p1->num);out=getchar();
printf("请输入第%d个学生的姓名:",total+1);
gets(p1->name);out=getchar();out=getchar();
printf("请输入第%d个学生的性别:",total+1);
scanf("%c",&p1->sex);out=getchar();
printf("请输入第%d个学生的年龄:",total+1);
scanf("%d",&p1->age);
for(i=0;i<7;i++)
{
printf("请输入第%d个学生的第%d门成绩:",total+1,i+1);continue;
scanf("%f",&p1->score[i][0]);
}
for(;total<=sum+n-1;total++)
{
if(total==0)
{
head=p1;
continue;
}
else
p2->next=p1;
p2=p1;
p1=(student *)malloc(LEN1);
printf("请输入第%d个学生的学号:",total+1);
gets(p1->num);out=getchar();
printf("请输入第%d个学生的姓名:",total+1);
gets(p1->name);out=getchar();
printf("请输入第%d个学生的性别:",total+1);
scanf("%c",&p1->sex);out=getchar();
printf("请输入第%d个学生的年龄:",total+1);
scanf("%d",&p1->age);
for(i=0;i<7;i++)
{
printf("请输入第%d个学生的第%d门成绩:",total+1,i+1);
scanf("%f",&p1->score[i][0]);out=getchar();
}
}
p2->next=NULL;
return(head);
}
}
for里面那个continue是我测试的时候加进去的
头文件里的代码
#define LEN1 sizeof(struct student)
struct student
{
char num[11];
char name[10];
char sex;
int age;
float score[7][1];
struct student *next;
};
student* creat(int n,student *head);
student* input(struct student *head);

for(i=0;i<7;i++)
{
printf("请输入第%d个学生的第%d门成绩:",total+1,i+1);continue;/*是不是不执行下面这句了*/
scanf("%f",&p1->score[i][0]);
}