| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 424 人关注过本帖
标题:[求助]怎么改,才能在该键表中删除指定序号的元素,再显示键表?
只看楼主 加入收藏
autumnluo
Rank: 1
等 级:新手上路
帖 子:40
专家分:0
注 册:2005-12-7
收藏
 问题点数:0 回复次数:2 
[求助]怎么改,才能在该键表中删除指定序号的元素,再显示键表?

怎么改,才能在该键表中删除指定序号的元素,再显示键表?
#include<iostream.h>
struct node
{
int date;
node*next;
};
node*deleteData(int n,node*head);
void*outputList(node*);
int main()
{
int n;
int num;

node *listHead=NULL;
cout<<"plaese enter the number of nodes:";
cin>>n;
cout<<"pleaase enter"<<n<<"intebers:";
for(int i=0;i<n;i++)
{cin>>num;
}
outputList(listHead);

cin>>num;
cout<<"\nplease enter the number tobe deleted:";
cin>>n;
listHead=deleteData(num,listHead);
outputList(listHead);
return 0;
}
node*deleteData(int n,node *head)
{node*curNode=head;
node*preNode=NULL;

cin>>n;
for(int i=1;i<=n;i++)
{preNode=curNode;
curNode=curNode->next;
}preNode->next=curNode->next;
delete curNode;
cout<<"delete"<<n<<"from the list."<<endl;
return head;

//末找到n
cout<<"can't find"<<n<<"in the list."<<endl;
return head;
}

搜索更多相关主题的帖子: include number 元素 
2006-04-18 10:37
pthouge
Rank: 1
等 级:新手上路
帖 子:48
专家分:0
注 册:2006-3-10
收藏
得分:0 
outputList(listHead)这个函数在哪?

2006-04-18 13:30
pthouge
Rank: 1
等 级:新手上路
帖 子:48
专家分:0
注 册:2006-3-10
收藏
得分:0 
你应该把整个程序都放进来,别人看起来也比较容易.总不能让人家把整个程序都写一次把

2006-04-18 13:32
快速回复:[求助]怎么改,才能在该键表中删除指定序号的元素,再显示键表?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.027935 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved