静态链表的建立
/*静态链表的建立*/#include <stdio.h>
struct student
{
int num;
float score;
struct student *next;
};
int main()
{
struct student a,b,c,*head;
a.num = 1;a.score = 98.5;
b.num = 2;b.score = 99.5;
c.num = 3;c.score = 97.5;
head = &a;
a.next = &b;
b.next = &c;
c.next = NULL;
do
{
printf("%ld%5.1f\n",head->num,head->score);
head = head->next;
}while(head != NULL);
return 0;
}
页:
[1]