C++编程:编写一个函数print,将第6题建立的链表中各结点的数据依次输出。
以下是此题的【c++源代码】
#include <iostream>
using namespace std;
#define NULL 0
struct student
{long num;
float score;
student *next;
};
int n;
void print(student *head)
{student *p;
cout<<"Now,These "<<n<<" records are:"<<endl;
p=head;
if(head!=NULL)
do
{cout<<p->num<<" "<<p->score<<endl;
p=p->next;
}while(p!=NULL);
}
来源:c++程序设计第三版谭浩强课后答案
本文链接:http://www.wb98.com/cjia/post/cjia_7.7.html