#include "stdio.h"
#include<malloc.h>
#include<string.h>
#include<ctype.h>
#define LEN struct student
struct student{
int num;
int score;
struct student*next;
};
struct student*create()
{
char ch;
struct student *head;
struct student*p1,*p2;
int a=0;
printf("是否输入新数据:\n");
while(toupper(ch=getchar())=='Y')
{
p1=(LEN*)malloc(sizeof(LEN));
scanf("%d%d",&(*p1).num,&(*p1).score);
a++;
if(a==1)
head=p1;
else
(*p2).next=p1;
p2=p1;
p1->next=NULL;
}
return(head);
}
void print(struct student *head)
{
struct student *p;
p=head;
while(p!=NULL)
{
printf("\n学号:%d,成绩:%d",p->num,p->score);
p=p->next;
}
}
void main( ){
print(create());
}
zy112
相关分类