首页 > 编程语言 > 详细

c++学习-链表

时间:2015-06-28 14:01:53      阅读:268      评论:0      收藏:0      [点我收藏+]

 

静态链表:

#include<iostream>
#include<string>
using namespace std;


struct book{
    int num;
    float price;
    struct book *next;
};

int main()
{
    book x, y, z, *head, *p;
    x = {1,1.1f};
    y = { 2, 2.2f };
    z = { 3, 3.3f };

    head = &x;
    x.next = &y;
    y.next = &z;
    z.next = NULL;

    p = head;
    while (p!=NULL)
    {
        cout << p->num<<\t<<p->price << endl;
        p = p->next;
    }
    return 0;
}

 

c++学习-链表

原文:http://www.cnblogs.com/siqi/p/4605395.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!