码迷,mamicode.com
首页 > 其他好文 > 详细

单链表练习

时间:2017-09-26 01:10:36      阅读:189      评论:0      收藏:0      [点我收藏+]

标签:练习   for循环   bsp   int   个学生   oat   turn   nbsp   student   

#include struct student //定义一个学生类 { int num; float score; struct student * next; }; int main() { struct student s1={8001,93.5},s2={8002,67.5},s3={8003,78}; struct student *head,*p;//定义头指针和指针 head = &s1;//head指向s1,s1.next指向s2,s2.next指向s3,s3.next指向NULL。 s1.next = &s2; s2.next = &s3; s3.next = NULL; for (p = head;p != NULL;p=p->next)//for循环,p指向下一个结点 printf("%d\t%.1f\n",p->num,p->score); return 1; }

 

单链表练习

标签:练习   for循环   bsp   int   个学生   oat   turn   nbsp   student   

原文地址:http://www.cnblogs.com/666fengmo666/p/7594499.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!