甚至是链表中的节点 [英] Even nodes in a linked list

查看:111
本文介绍了甚至是链表中的节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编写一个C程序来显示链表中的偶数节点。



我尝试过:



我已经编写了程序并编译了它。程序显示没有错误。但是我没有得到所需的结果。因为我输入的是1-> 3> 2→6-&将7-大于10;我应该得到输出为2-> 6-> 10 ...但是得到输出为1-> 3-> 2-> 6.Can有人请帮帮我??

Write a C program to display the even nodes in a linked list.

What I have tried:

I have written the program and compiled it.The program is showing no errors.But I am not getting the desired result.Since my input is given as 1->3->2->6->7->10; I should get the output as 2->6->10...but am getting the output as 1->3->2->6.Can someone please help me??

推荐答案

我们无法帮助您 - 它需要您的数据,并在代码运行该数据时查看正在发生的事情。我们没有您的数据,我们没有您的整个应用程序 - 如果我们这样做,我们也不知道如何使用它!



所以,它取决于你。

在函数的第一行放置断点,并通过调试器运行代码。然后查看您的代码,并查看您的数据并找出手动应该发生的事情。然后单步执行每一行检查您预期发生的情况正是如此。如果不是,那就是当你遇到问题时,你可以回溯(或者再次运行并仔细观察)以找出原因。


对不起,但我们不能为你做到这一点 - 时间让你学习一门新的(非常非常有用的)技能:调试!
We can't help you with this - it needs your data, and to be looking at what is happening while the code is running on that data. And we don't have your data, we don't have your whole app - and we don't know how to use it if we did!

So, its going to be up to you.
Put a breakpoint on the first line in the function, and run your code through the debugger. Then look at your code, and at your data and work out what should happen manually. Then single step each line checking that what you expected to happen is exactly what did. When it isn't, that's when you have a problem, and you can back-track (or run it again and look more closely) to find out why.

Sorry, but we can't do that for you - time for you to learn a new (and very, very useful) skill: debugging!


Quote:

我编写了程序并编译了它。程序显示没有错误。

I have written the program and compiled it.The program is showing no errors.



这意味着你的代码尊重语法语言,并不意味着代码完成了预期的工作。

猫在天空飞得很高是一句尊重Ebglish语法的句子,但没有任何意义。


This means that your code respects the syntax of the language, it doesn't mean that the code does what is expected.
"the cat flies high in the sky" is a sentence that respect Ebglish syntax, but means nothing.

Quote:

但是我没有得到理想的结果。

But I am not getting the desired result.



这是典型的一个有缺陷的代码。尝试显示代码以获得真正的帮助,或者学习调试器。

-----

有一个工具可以让你看到你的代码在做什么,它的名字是调试器。它也是一个很好的学习工具,因为它向你展示了现实,你可以看到哪种期望与现实相符。

当你不明白你的代码在做什么或为什么它做它做的时候,答案就是答案是调试器

使用调试器查看代码正在执行的操作。只需设置断点并查看代码执行情况,调试器允许您逐行执行第1行并在执行时检查变量。



调试器 - 维基百科,免费的百科全书 [ ^ ]



掌握Visual Studio 2010中的调试 - 初学者指南 [ ^ ]

使用Visual Studio 2010进行基本调试 - YouTube [ ^ ]

调试器在这里向您展示您的代码正在做什么,您的任务是与什么进行比较应该这样做。

调试器中没有魔法,它没有找到错误,它只是帮助你。当代码没有达到预期的效果时,你就会接近一个错误。


That is typical from a buggy code. try to show code for real help, or learn debugger.
-----
There is a tool that allow you to see what your code is doing, its name is debugger. It is also a great learning tool because it show you reality and you can see which expectation match reality.
When you don't understand what your code is doing or why it does what it does, the answer is debugger.
Use the debugger to see what your code is doing. Just set a breakpoint and see your code performing, the debugger allow you to execute lines 1 by 1 and to inspect variables as it execute.

Debugger - Wikipedia, the free encyclopedia[^]

Mastering Debugging in Visual Studio 2010 - A Beginner's Guide[^]
Basic Debugging with Visual Studio 2010 - YouTube[^]
The debugger is here to show you what your code is doing and your task is to compare with what it should do.
There is no magic in the debugger, it don't find bugs, it just help you to. When the code don't do what is expected, you are close to a bug.


这篇关于甚至是链表中的节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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