初试链表

来源:互联网 发布:网络爬虫 demo .net 编辑:程序博客网 时间:2024/06/18 15:24
#include <stdio.h>#define students Astruct A{    int num;    double score;    struct A *next;};int main(){    struct A a,b,c,*head,*p;    a.num=10000;    a.score=80.2;    b.num=20000;    b.score=87.5;    c.num=30000;    c.score=98.5;    head=&a;    a.next=&b;    b.next=&c;    c.next=NULL;    p=head;    do{        printf("%d %.2lf\n",p->num,p->score);        p=p->next; //使链表一直往后    }    while (p!=NULL);    return 0;}



0 0