//建立简单单链表
#include <stdio.h>
struct student{
int num;
float score;
struct student *next;
};
int main(){
struct student a,b,c,*head,*p;
a.num=10101;a.score=98.5;
b.num=10103;b.score=78;
c.num=10106;c.score=87.9;
head=&a;
a.next=&b;
b.next=&c;
c.next=NULL;
p=head;
while(p!=NULL){
printf("%d %5.2f\n",p->num,p->score);
p=p->next;
}
return 0;
}
#include <stdio.h>
struct student{
int num;
float score;
struct student *next;
};
int main(){
struct student a,b,c,*head,*p;
a.num=10101;a.score=89.5;
b.num=10103;b.score=90;
c.num=10107;c.score=85;
head=&a;
a.next=&b;
b.next=&c;
c.next=NULL;
p=head;
do{
printf("%ld %5.1f\n",p->num,p->score);
p=p->next;
}while(p!=NULL);
return 0;
}