C语言--链表

#include<stdio.h>
#include<stdlib.h>
#define NULL 0
struct student
{
    long num;
    float score;
    struct student *next;
};
int main()
{
    struct student a,b,c,*head,*p;
    a.num=99101;
    a.score=89.5;
    b. num=99103;
    b.score=90;
    c.num=99107 ;
    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;
}

  

猜你喜欢

转载自www.cnblogs.com/wkfvawl/p/9243648.html