请问下面的while(1)和while(head)分别是什么意思啊?#include struct Student{ long num;float score;Student* next;};Student* pHead=NULL; //链首指针void Create(){ Student* pS; //当前插入的结点指针Student* pEnd; //链尾指

来源:学生作业帮助网 编辑:作业帮 时间:2024/07/21 04:44:05
请问下面的while(1)和while(head)分别是什么意思啊?#include struct Student{ long num;float score;Student* next;};Student* pHead=NULL; //链首指针void Create(){ Student* pS; //当前插入的结点指针Student* pEnd; //链尾指
xT]o`+MAc ct҈-"& IU`0mfP7F]_m{|t#bw4=9s9 ťӕ96>I.^䥫:jT0\B7ܾUIȸXRmoᰢrK A %`rTd;DflrWV^܊t4ijy.ѕqv+|h7h$:,:ot@ >JS Ӻቶ{p&2nߒkM:+@s,sr"%^p! v.j7+;}ޗVTlY{d[I!Ტol/~{

请问下面的while(1)和while(head)分别是什么意思啊?#include struct Student{ long num;float score;Student* next;};Student* pHead=NULL; //链首指针void Create(){ Student* pS; //当前插入的结点指针Student* pEnd; //链尾指
请问下面的while(1)和while(head)分别是什么意思啊?
#include
struct Student
{ long num;
float score;
Student* next;
};
Student* pHead=NULL; //链首指针
void Create()
{ Student* pS; //当前插入的结点指针
Student* pEnd; //链尾指针
pS=new Student; //为第一个结点动态开辟堆内存
cin>>pS->num>>pS->score; //给第一个结点赋值
pHead=pS; //链首指针指向第一个结点
pEnd=pS; //链尾指针指向第一个结点
while(1)
{ pS=new Student; //下一个结点
cin>>pS->num>>pS->score;
if(pS->num==0)
break;
pEnd->next=pS; //原结点
pEnd=pS; //新结点
}
pEnd->next=NULL; //最后结点指针
delete pS;
}
void ShowList(Student* head)
{ cout

请问下面的while(1)和while(head)分别是什么意思啊?#include struct Student{ long num;float score;Student* next;};Student* pHead=NULL; //链首指针void Create(){ Student* pS; //当前插入的结点指针Student* pEnd; //链尾指
while(1)表示从键盘输入来构建链表,直到用户输入num值为0时终止输入.
while(head)表示链表不为空而且没有到达链表尾部时将链表的值输出到标准输出设备(屏幕).