第二周(课上例题)——建立和输出一个简单的链表

来源:互联网 发布:淘宝抢拍在哪 编辑:程序博客网 时间:2024/05/17 16:03
/*烟台大学计算机学院学生*All rights reserved.*文件名称:建立和输出一个简单的链表*作者:王洪海*完成日期:2013年3月5日*版本号:v1.01*对任务及求解方法的描述部分::建立和输出一个简单的链表我的程序:*/#include <iostream>using namespace std;struct Student{    long num;    float score;    struct Student *next;};int main(){    Student a,b,c,*head,*p;    a.num=31001;a.score=89.5;    b.num=31003;b.score=90;    c.num=31007;c.score=85;    head=&a;    a.next=&b;    b.next=&c;    c.next=NULL;    p=head;    do    {        cout<<p->num<<"  ";        cout<<p->score<<endl;        p=p->next;    }while(p!=NULL);    return 0;}

运行结果,如下图:




对链表的的初步认识,通过敲打键盘慢慢熟悉!!

0 0
原创粉丝点击