📄 10_4_3.cpp
字号:
//10_4_3
#include <iostream.h>
struct Lnode
{
double data;
Lnode* next;
};
void ShowList(Lnode* head);
void AddToEnd(Lnode* pnew, Lnode*& head);
Lnode* GetNode();
void DeleteList(Lnode* head);
void main()
{
Lnode* head=NULL;
Lnode* temp;
double d;
cout <<"data? ";
cin >>d;
while(d>0&&(temp=GetNode())){
temp->data=d;
AddToEnd(temp, head);
cout <<"data? ";
cin >>d;
}
ShowList(head);
DeleteList(head);
}
void ShowList(Lnode* head)
{
if(head){
cout <<head->data <<endl;
if(head->next)
ShowList(head->next); //递归调用
}
}
void AddToEnd(Lnode* pnew, Lnode*& head)
{
if(!head){
head=pnew;
pnew->next=NULL;
}else
AddToEnd(pnew, head->next); //递归调用
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -