| 首页 | 新闻 | 网页 | 设计 | 色彩 | 原创 | 视觉 | 素材 | 动漫 | 酷站 | 策划 | 文案 | 访谈 | 运营 | 编程 | 数据库 | 服务器 | 下载 | 图库 | 
您的位置: 幽幽天空 > 网页 > 编程开发 > Visual C++教程 > 文章正文 用户登录
一个站点要运营成
迅雷联盟:个人站
迅雷联盟,个人站
一个失败者的网站
从名片看到一个小
一个大学生的网页
网络新生领域扫描
一个站长建站经历
一个网络创业者的
广捷居 一个永不言

编一个有十个节点的链表           

编一个有十个节点的链表

作者:佚名 来源:CSDN 作者: quanh 更新:2006-8-25 21:05:35 错误报告 我要投稿

#include<iostream.h>
class node//
{
public:
    node *next;
 int data;
 node(const int & item ,node *ptrnext=NULL);//构造
 void   insertafter(node*p);//插入
 node  *thisnode(void);//返回本节点的指针
};
node::node(const int&item,node *ptrnext)
{
 data=item;
 next=ptrnext;

}
void node::insertafter(node*lastptr)
{
 lastptr->next=this->next;
 this->next=lastptr;
}
node  *node::thisnode(void)
{return this;}
void  main()
{
 int a,i;
 node  *lastptr,*head,*currptr; cout<<"please input a:   "<<endl;
 cin>>a; 
   node   example1(a);
 head=example1.thisnode();
 currptr=head;
    for(i=0;i<9;i++)
 {
   lastptr=example1.thisnode();
   cin>>a; 
   node   example1(a);
   example1.insertafter(lastptr);
  }
 cout<<endl;
    while (currptr!=NULL)
 {
  cout<<currptr->data;
        currptr=currptr->next;
 }
}

请问这个程序应怎样修改?谢谢

文章录入:skyuu    责任编辑:skyuu 
  • 上一篇文章:

  • 下一篇文章:
  • 【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
    网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
    发表评论:
    姓名:  评 分: 1分 2分 3分 4分 5分
     
  • 严禁发表危害国家安全、政治、黄色淫秽等内容的评论。
  • 用户需对自己在使用幽幽天空服务过程中的行为承担法律责任。
  • 本站管理员有权保留或删除评论内容。
  • 评论内容只代表机友个人观点,与本网站立场无关。