当我在linux上尝试相同的代码时,为什么执行结果会改变? [英] Why the excecution result changes when i try the same code on linux ?

查看:73
本文介绍了当我在linux上尝试相同的代码时,为什么执行结果会改变?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个程序(这是一个大学任务)它确实在Windows上编译和运行,但是当我复制它在linux上编译它,它编译并运行成功,但给出其他结果,我一直在试图为什么在过去的10个小时里,我不能,


i已经在Linux上进行了调试,并发现tere是一个整数数组,其值自动更改,我的意思是没有任何代码操纵值,

(这种意想不到的变化只发生在linux上运行时)

i必须交付作业tommorow,这是紧急的

任何人都可以提供帮助?

解决方案

我们需要更多信息,例如代码片段或输出,以便能够为您提供帮助。


< blockquote>谢谢

问题是因为调试代码不再具有可读性


练习是背包问题而且我编写了残酷的算法和结果是我们应该放在背包中的项目数组以实现最佳解决方案

所以在windows上它给出了正确的数组(这是最佳解决方案)

在linux上它确实不给出相同的数组但是随机数组


这里是代码

但它需要一个文本输入文件来执行





附加文件
Code.zip (1.4 KB,42次观看)


I have a program (which is a university assignment) it does compile and run correctly on windows, but when i copy it an compile it on linux, it compiles and run successful but gives other results, i have been trying to figure out why for the last 10 hours and i could not ,

i have done debuging on Linux, and discovered that tere is an array of integer which values change automatically, i mean without any code that manipulaties the values,
(this unexpected change occurs only when i run on linux )
i have to deliver the assignment tommorow , it is urgent
anyone can help ?

解决方案

We need more information, such as a code snippet or output, to be able to help you.


thanks
the problem is that because of debugging the code in no more readable

the exercise is Knapsack problem and i have coded brutal force algorithms and the result is an array of the item which we should put in the knapsack to achieve optimal solution
so on windows it gives the right array (which yeilds the optimal solution)
on linux it does not give the same array but a random array


here is the code
but it need a text input file to be executed

Attached Files
Code.zip (1.4 KB, 42 views)


这篇关于当我在linux上尝试相同的代码时,为什么执行结果会改变?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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