#include "iostream.h" struct Lnode
{
double data;
Lnode *next;
};
void ShowList(Lnode * list)
{
if(list)
{
cout<<list->data<<endl;
if(list->next)
ShowList(list->next);
}
}
void AddToEnd(Lnode *new1,Lnode *head)
{
if(head==NULL)
{
head=new1;
new1->next=NULL;
}
else
AddToEnd(new1, head->next);
}
Lnode *GetNode()
{
Lnode * item;
item=new Lnode;
if(item)
{
item->next=NULL;
item->data=0;
}
else
cout<<"Nothing allocated\n";
return item;
}
void main()
{
Lnode *head=NULL;//链首
Lnode *temp;
temp=GetNode();
while (temp)
{
cout<<"data:";
cin>>temp->data;
if(temp->data>0)
AddToEnd(temp,head);
else
break;
temp=GetNode();
}
ShowList(head);
}
{
double data;
Lnode *next;
};
void ShowList(Lnode * list)
{
if(list)
{
cout<<list->data<<endl;
if(list->next)
ShowList(list->next);
}
}
void AddToEnd(Lnode *new1,Lnode *head)
{
if(head==NULL)
{
head=new1;
new1->next=NULL;
}
else
AddToEnd(new1, head->next);
}
Lnode *GetNode()
{
Lnode * item;
item=new Lnode;
if(item)
{
item->next=NULL;
item->data=0;
}
else
cout<<"Nothing allocated\n";
return item;
}
void main()
{
Lnode *head=NULL;//链首
Lnode *temp;
temp=GetNode();
while (temp)
{
cout<<"data:";
cin>>temp->data;
if(temp->data>0)
AddToEnd(temp,head);
else
break;
temp=GetNode();
}
ShowList(head);
}
解决方案 »
- combobox中调用了OnCbnSelchangeCombo1()之后的问题??小弟用的是vs08
- 求真实地形数据 GTOPO_30的数据格式,即(*.DEM文件的数据格式)
- InvalidateRect()
- 如何让CListCtrl中的某一行高亮显示
- 关于MSCOMM32.OCX注册的问题,急等
- 如和在点击“OK”关闭子对话框(CDialog类)后更新主视图里的内容??
- 在线求教:CDC中再使用SetMapMode(MM_HIENGLISH)设置坐标映射方式时,不能显示正确的坐标系?
- CHM格式文档能进行版本保护吗?
- 请问如何获取当前程序的运行路径?
- 关于指针的问
- 怎样用程序打开一个目录??
- 请大虾给小弟看看~!下面的代码是什么意思~~~!谢谢了
就是看不到!我再贴一回:
#include "stdafx.h"
#include "iostream.h" struct Lnode
{
double data;
Lnode *next;
};
void ShowList(Lnode * list)
{
if(list)
{
cout<<list->data<<endl;
if(list->next)
ShowList(list->next);
}
}
void AddToEnd(Lnode *new1,Lnode *head)
{
if(head==NULL)
{
head=new1;
new1->next=NULL;
}
else
AddToEnd(new1, head->next);
}
Lnode *GetNode()
{
Lnode * item;
item=new Lnode;
if(item)
{
item->next=NULL;
item->data=0;
}
else
cout<<"Nothing allocated\n";
return item;
}
void main()
{
Lnode *head=NULL;//链首
Lnode *temp;
temp=GetNode();
while (temp)
{
cout<<"data:";
cin>>temp->data;
if(temp->data>0)
AddToEnd(temp,head);
else
break;
temp=GetNode();
}
ShowList(head);
}