| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 490 人关注过本帖
标题:单链表的建立插入删除查找哪位大神帮忙看下这个程序哪里错了
取消只看楼主 加入收藏
winner1995
Rank: 2
等 级:论坛游民
帖 子:64
专家分:41
注 册:2015-10-11
结帖率:88.89%
收藏
已结贴  问题点数:20 回复次数:3 
单链表的建立插入删除查找哪位大神帮忙看下这个程序哪里错了
#include<stdio.h>
#include<iostream.h>
#include<stdlib.h>
int n;
typedef struct lnode{
    int data;
    struct lnode * next;
}lnode, * linklist;
linklist p;
void createlist(linklist L)
{cout<<"plese enter you hope data'number:"<<endl;
cin>>n;
int i;
L=(linklist)malloc(sizeof(lnode));
L->next=NULL;
cout<<"please enter your data:"<<"\f";
for(i=n;i>0;--i)
{p=(linklist)malloc(sizeof(lnode));
cin>>p->data;
p->next=L->next;
L->next=p;
}
cout<<"your linklist is:"<<"\f";
for(i=n;i>0;--i)
{cout<<p->data<<"\f";
p=p->next;
}
}
void getlist(linklist L)
{int i,j;
p=L->next;
j=1;
cout<<"please enter your searching'place:"<<"\f";
cin>>i;
while(p&&j<i)
{p=p->next;
++j;
}
if(!p||j>i)
cout<<"the i don't exist";
cout<<"your searching is:"<<"\f";
cout<<p->data;
}
void listinsert(linklist L)
{int i,j,e;
linklist s;
p=L;
j=0;
cout<<"please enter want before which insert:"<<endl;
cin>>i;
cout<<"please enter inserting'number:";
cin>>e;
while(p&&j<i-1)
{p=p->next;
++j;}
if(!p||j>i-1)
cout<<"i is error"<<endl;
s=(linklist)malloc(sizeof(lnode));
s->data=e;
s->next=p->next;
p->next=s;
cout<<"now the linklist is:"<<"\f";
for(i=n=1;i>0;--i)
{cout<<p->data<<"\f";
p=p->next;}
}
void listdelete(linklist L)
{int i,j;
linklist q;
p=L;
j=0;
cout<<"enter you want delete's xuhao:"<<"\f";
cin>>i;
while(p->next&&j<i-1)
{p=p->next;
++j;
}
if(!(p->next)||j>i-1)
cout<<"i is error"<<endl;
{q=p->next;
p->next=q->next;
free(q);
cout<<"deleting finish";}
cout<<"now the linklist is:"<<"\f";
for(i=n;i>0;--i)
{cout<<p->data<<"\f";
p=p->next;
}
cout<<endl;
}
int mian()
{
    linklist L1;
    createlist(L1);
    getlist(L1);
    listinsert(L1);
    listdelete(L1);
    return 0;
}
搜索更多相关主题的帖子: include please number 
2015-10-18 20:13
winner1995
Rank: 2
等 级:论坛游民
帖 子:64
专家分:41
注 册:2015-10-11
收藏
得分:0 
回复 2楼 a1925212437
-------------------Configuration: lianbiao - Win32 Debug--------------------
Linking...
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/lianbiao.exe : fatal error LNK1120: 1 unresolved externals
执行 link.exe 时出错.

lianbiao.exe - 1 error(s), 0 warning(s)

唯望君安~
2015-10-18 20:40
winner1995
Rank: 2
等 级:论坛游民
帖 子:64
专家分:41
注 册:2015-10-11
收藏
得分:0 
回复 4楼 a1925212437
运行出来了   多谢大神

唯望君安~
2015-10-19 16:47
winner1995
Rank: 2
等 级:论坛游民
帖 子:64
专家分:41
注 册:2015-10-11
收藏
得分:0 
回复 4楼 a1925212437
换成c++就运行不出来了  真是怪了

唯望君安~
2015-10-19 17:28
快速回复:单链表的建立插入删除查找哪位大神帮忙看下这个程序哪里错了
数据加载中...
 
   



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

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