网页
资讯
视频
图片
知道
文库
贴吧
地图
采购
进入贴吧
全吧搜索
吧内搜索
搜贴
搜人
进吧
搜标签
日
一
二
三
四
五
六
签到排名:今日本吧第
个签到,
本吧因你更精彩,明天继续来努力!
本吧签到人数:0
一键签到
成为超级会员,使用一键签到
一键签到
本月漏签
0
次!
0
成为超级会员,赠送8张补签卡
如何使用?
点击日历上漏签日期,即可进行
补签
。
连续签到:
天 累计签到:
天
0
超级会员单次开通12个月以上,赠送连续签到卡3张
使用连续签到卡
06月22日
漏签
0
天
c语言吧
关注:
791,087
贴子:
4,300,570
看贴
图片
吧主推荐
视频
游戏
9
回复贴,共
1
页
<<返回c语言吧
>0< 加载中...
求助
链表的相关问题
只看楼主
收藏
回复
可以抓注意次数
大能力者
8
该楼层疑似违规已被系统折叠
隐藏此楼
查看此楼
在写链表倒转的题目,写了后先出了next不在成员里。然后把别名改了用原名这个next和缺少说明符的问题就没了,然后就是变量未初始化,随后new了内存,结果最后运行了,但是没有任何输出。
我的预期里应该会是我先输入链表数据随后打印,然后倒转再打印,但是直接卡死了
可以抓注意次数
大能力者
8
该楼层疑似违规已被系统折叠
隐藏此楼
查看此楼
上网查了下next是作用域问题,声明了下但是依旧没有输出。
可以抓注意次数
大能力者
8
该楼层疑似违规已被系统折叠
隐藏此楼
查看此楼
看了下,最终的编译显示生成1,失败0,成功0,这个是什么情况嘛?
究极小白
帕秋莉糕
12
该楼层疑似违规已被系统折叠
隐藏此楼
查看此楼
建议把全部代码发出来
可以抓注意次数
大能力者
8
该楼层疑似违规已被系统折叠
隐藏此楼
查看此楼
#include <iostream>
#include <cmath>
#include<iomanip>
#include<cstring>
using namespace std;
typedef struct entity ETY;
typedef struct entity
{
int data;
ETY *next;
}ETY;
ETY* head;
void chaininsert(int e)
{
ETY* newdata, *temp;
newdata = new ETY;
temp = new ETY;
newdata->data = e;
newdata->next = NULL;
temp = head;
while (temp->next != NULL)
temp->next = temp->next->next;
temp->next = newdata;
head->data = head->data + 1;
}
void mutiple_chaininsert( int b)
{
int a;
for (int i = 0; i < b; i++)
{
cout << "enter a number" << endl;
cin >> a;
chaininsert(a);
}
}
void coutchain(int a)
{
ETY* temp;
temp = head->next;
for (int i = 0; i <= a; i++)
{
cout << temp->data<<",";
temp = temp->next;
}
}
void chain_reverse()
{
ETY* temp,*pre,*form;
temp = head;
pre = NULL;
form = head->next;
if (temp->next == NULL)
return ;
else
{
temp->next = pre;
pre = temp;
temp = form;
form = form->next;
}
}
int main()
{
head->data = 0;
head->next = NULL;
int a = 0;
mutiple_chaininsert(10);
coutchain(head->data);
chain_reverse();
coutchain(head->data);
return 0;
}
究极小白
帕秋莉糕
12
该楼层疑似违规已被系统折叠
隐藏此楼
查看此楼
你对链表的操作并不是很熟悉,错误有点多,对着一个个看把
#include <iostream>
#include <cmath>
#include<iomanip>
#include<cstring>
using namespace std;
typedef struct entity ETY;
typedef struct entity
{
int data;
ETY* next;
}ETY;
ETY* head;
void chaininsert(int e)
{
ETY* newdata, * temp;
newdata = new ETY;
temp = new ETY;
newdata->data = e;
newdata->next = NULL;
temp = head;
while (temp->next != NULL)
temp= temp->next;
temp->next = newdata;
head->data = head->data + 1;
}
void mutiple_chaininsert(int b)
{
int a;
for (int i = 0; i < b; i++)
{
cout << "enter a number" << endl;
cin >> a;
chaininsert(a);
}
}
void coutchain(int a)
{
ETY* temp;
temp = head->next;
for (int i = 0; i <a-1; i++)
{
cout << temp->data << ",";
temp = temp->next;
}
cout << temp->data << endl;
}
void chain_reverse()
{
ETY* temp, * pre, * form;
temp = head->next;
pre = NULL;
form = head->next;
if (temp == NULL)
return;
else
{
//temp->next = NULL;
while (temp!= NULL) {
temp = temp->next;
form->next = pre;
pre = form;
form = temp;
}
head->next = pre;
/*temp->next = pre;
pre = temp;
temp = form;
form = form->next;*/
}
}
int main()
{
head = new ETY;
head->data = 0;
head->next = NULL;
int a = 0;
mutiple_chaininsert(10);
coutchain(head->data);
chain_reverse();
coutchain(head->data);
return 0;
}
登录百度账号
扫二维码下载贴吧客户端
下载贴吧APP
看高清直播、视频!
贴吧页面意见反馈
违规贴吧举报反馈通道
贴吧违规信息处理公示