标题:[求助]不会改了,小生愚蠢?
取消只看楼主
autumnluo
Rank: 1
等 级:新手上路
帖 子:40
专家分:0
注 册:2005-12-7
 问题点数:0 回复次数:0 
[求助]不会改了,小生愚蠢?

#include<iostream.h>
struct node
{
int date;
node*next;
};
node*deleteData(int n,node*head);
void*outpputList(node*head);
int main()
{
int n;
int num;

node *listHead=NULL;
cout<<"plaese enter the number of nodes:";
cin>>n;
cout<<"pleaase enter"<<n<<"intebers:";
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;
}
void *outputList(node*head)
{
cout<<"list:";
node *curNode=head;
while(curNode)
{
cout<<curNode->data;
if(curNode->next)
cout<<"->";
curNode=curNode->next;
}
cout<<endl;
return;}

搜索更多相关主题的帖子: 小生 
2006-04-18 10:47



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-58231-1-1.html




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

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