简单静态链表的使用

struct Student{
    int num;
    float score;
    struct Student *next;
};
//简单静态链表使用
int main(int argc, const char * argv[]) {
    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("\t %5.1f\n",p->num,p->score);
        p=p->next;
    }while(p!=NULL);
    return 0;
}
打印结果:
10101   89.5
10103   90.0
10107   85.0

 

posted @ 2017-07-13 19:08  零度咖啡  阅读(113)  评论(0)    收藏  举报