/*
* 程序的版权和版本声明部分
* Copyright (c)2012, 烟台大学计算机学院学生
* All rightsreserved.
* 文件名称: fun.cpp
* 作 者:王飞
* 完成日期:2012 年12月 30日
* 版本号: v1.0
* 对任务及求解方法的描述部分:学习静态链表
* 输入描述:略
* 问题描述:略
* 程序输出:如下
*/
#define NULL 0
#include <iostream>
using namespace std;
struct student
{
int num;
float score;
struct student *next;
};
int main()
{
student a,b,c,*head,*p;
a.num=12334;
a.score=23;
b.num=12336;
b.score=34;
c.num=12340;
c.score=41;
head=&a;
a.next=&b;
b.next=&c;
c.next=NULL;
p=head;
do
{
cout<<p->num<<'\t'<<p->score<<endl;
p=p->next;
}while(p!=NULL);
return 0;
}
截图:
心得体会:
C++中的链表就像一根针线穿起来一样,做到有头有尾.