插入号码其他一些没有。在链接列表中 [英] Inserting a no. after some other no. in link list

查看:68
本文介绍了插入号码其他一些没有。在链接列表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我为插入编号而编写的代码,在给出否后。在一个链接列表中;

i猜测逻辑是正确的。

没有错误,

但是在显示它的时候不显示更新的值。

Here is the code i hav written for inserting a no., after given no. in a link list;
i guess the logic is ofcourse right.
there is no error in it,
but at the time of display its not displaying the updated value.

展开 | 选择 | Wrap | < span class =codeLinkonclick =LineNumbers(this);>行号

推荐答案

那么它打印出来的是什么?
So what does it print out?


为什么在插入链表的函数中有数据输入?这意味着你永远不能在其他地方使用这个功能,除非你接受数据输入,这也迫使你接受屏幕布局。


你应该做的是:


1)做数据输入

2)传递数据,指向链表的指针和插入函数的位置。


然后insertafter:

1)通过将数据传递给它来调用函数来创建节点。该函数返回一个指向新节点的指针。

2)遍历列表以找到插入点

- 确保保存上一个节点的下一个地址或者你无法插入

3)设置下一个节点旁边的新节点

4)设置新节点旁边的上一个节点


insertafter()中应该包含少于10行的代码。
Why is there data entry in a function that inserts into a linked list? That means you can never use this function anywhere else unless you accept the data entry, which also forces you to accept the screen layout.

What you should do is:

1) do the data entry
2) pass the data, a pointer to the linked list and the position to your insertafter function.

Then insertafter:
1) calls a funciton to create the node by passing the data to it. The function returns a pointer to the new node.
2) traverse the list to locate the insertion point
- be sure to save the next address of the previous node or you can''t insert
3) set the new node next to the previous node next
4) set the previous node next to the new node

The insertafter() should have less than 10 lines of code in it.



为什么有数据输入插入链表的函数?这意味着你永远不能在其他地方使用这个功能,除非你接受数据输入,这也迫使你接受屏幕布局。


你应该做的是:


1)做数据输入

2)传递数据,指向链表的指针和插入函数的位置。


然后insertafter:

1)通过将数据传递给它来调用函数来创建节点。该函数返回一个指向新节点的指针。

2)遍历列表以找到插入点

- 确保保存上一个节点的下一个地址或者你无法插入

3)设置下一个节点旁边的新节点

4)设置新节点旁边的上一个节点


insertafter()中应该包含少于10行的代码。
Why is there data entry in a function that inserts into a linked list? That means you can never use this function anywhere else unless you accept the data entry, which also forces you to accept the screen layout.

What you should do is:

1) do the data entry
2) pass the data, a pointer to the linked list and the position to your insertafter function.

Then insertafter:
1) calls a funciton to create the node by passing the data to it. The function returns a pointer to the new node.
2) traverse the list to locate the insertion point
- be sure to save the next address of the previous node or you can''t insert
3) set the new node next to the previous node next
4) set the previous node next to the new node

The insertafter() should have less than 10 lines of code in it.



这是一种做法;但我确定我的方式是正确的!

我已经写了一个插入功能;而不是用于创建节点!

我的输出是什么输出是我的原始列表;而不是我编辑过的那个.......

,就像这个函数所用的新值一样

That''s one way of doing it; but m sure even my way is right!
I have already written a function for insertion; and not for creating a node!
what output i grt by this is my original list; and not the one i have edited.......
as in the new value ebterwed by this function


这篇关于插入号码其他一些没有。在链接列表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆