|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
#include"stdio.h"
#include"malloc.h"
#include"stdio.h"
struct student
{
int number;
int score;
struct student *next;
};
void main()
{
void print_link(struct student *head);
struct student *creat();
struct student *p;
p=creat();
print_link(p);
}
struct student *creat()
{
struct student *p1,*p2;
struct student *head=NULL;
p1=p2=(struct student *)malloc(sizeof(struct student));
printf("输入编号:");
scanf("%d",&p1->number);
printf("输入分数:");
scanf("%d",&p1->score);
while(p2->number!=0)
{
p1=p2=(struct student *)malloc(sizeof(struct student));
printf("输入编号:");
scanf("%d",&p1->number);
printf("输入分数:");
scanf("%d",&p1->score);
p2->next=p1;
p2=p1;
}
return head;
}
void print_link(struct student *head)
{
struct student *p;
p=head;
while(p!=NULL)
{
printf("%d",p->number);
printf("%d",p->score);
p=p->next;
}
}
输出的结果感觉是死循环!高手看看! |
|