#include <string.h>
# include "stdlib.h"
#define LEN sizeof(struct stu)
struct stu
{
long num
char name[20]
char sex
int age
char addr[30]
struct stu *next
}
int main()
{
int n
struct stu *head
struct stu *p1,*p2
head=(struct stu*)malloc (LEN)
head->next=NULL
p1=head
p2=(struct stu*)malloc (LEN)
p2->next=NULL
printf("学号\t姓名\t性别\t年龄\t住址\n")
scanf("%ld,\t%s,\t%c,\t%d,\t%s",&p2->num,&p2->name,&p2->sex,&p2->age,&p2->addr)
while(p2->num!=0)
{
p1->next=p2
p1=p2
fflush(stdin)
p2=(struct stu*)malloc (LEN)
printf("学号\t姓名\t性别\t年龄\t住址\n")
scanf("%ld,%s,%c,%d,%s",&p2->num,&p2->name,&p2->sex,&p2->age,&p2->addr)
}
}
纯手打,希望采纳。
构造一个关于学生信息的数据类型如:
struct studengt_type
{
int number //学号
char *name//姓名
char sex//性别
int score// 入学成绩
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)