【C语言】建立静态链 并 输出链表

来源:互联网 发布:ubuntu mount ext4 编辑:程序博客网 时间:2024/06/04 18:33

建立一个简单链表,它由3个学生数据的节点组成,要求输出各节点的数据。

//静态链表#include<stdio.h>#include<windows.h>#include<string.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);    system("pause");    return 0;}

这里写图片描述

0 0
原创粉丝点击