问题描述
我只使用void函数编写了大部分程序。它们最终变得冗长而臃肿,因为我经常在每个void函数中反复编写相同的代码。我甚至对虚空功能感到困惑。这本书说虚空功能不会返回数据,但我让他们这样做。我正在使用void函数将数据发送到文件和屏幕。我使用void函数来创建随机数数组。然后其他void函数使用随机数组,就像从低到高排序一样。所以我知道他们会返回数据。在这个程序中,我创建了一个10 x 10显示两次并写入sceen并文件两次。如果我两次做同样的事情,我知道你可以发送数据,即打印到文件两次,一次排序,一次未排序。每当我尝试进行函数调用时,我都会遇到大量错误。我也是两次创建10 x 10显示器。我不能以某种方式将未分类和排序的数据发送到要格式化的相同功能并返回显示。以下是没有陈述的函数。在主要内容中,我评论了每个函数调用的作用。
I write most of my programs using only void function. They end up long and bloated because I often write the same code over and over again in each void function. I''m even confused by void functions though. The book says void functions don''t return data but I make them do it. I''m using a void function to send data to a file and the screen. I use a void function to create the random number array. Then the other void functions use the random array, like sort it low to high. So I know they return data. In this program I created a 10 x 10 display twice and wrote to sceen and file twice. If I''m doing the same thing twice I know you can send the data i.e. print to file twice ,once sorted, once unsorted. Whenever I try and do function calls I end up a huge amount of errors. Also I''m creating the 10 x 10 display twice. Can''t I somehow send the unsorted and sorted data to the same fuction to be formated and that be returned for display. Below are the functions without the statements. In main I have commented on what each function call does.
推荐答案
这通常是一个提示,你应该创建一个单独的函数来处理重复的代码。
That''s usually a hint that you should create a separate function to handle that repeated code.
不,他们不会返回数据。它们作为参数发送到函数的数组上运行。哪个好 - 从您的代码判断,这正是您想要的。但是他们没有回复任何东西。
No, they don''t return data. They operate on the array you sent as an argument to the function. Which is fine - judging by your code, that''s exactly what you want. But they don''t return anything.
发布错误文本。
Post the text of the errors.
为什么不发布完整代码?
Why don''t you post the full code?
论坛发帖规则说不是,这是不正确的?那就是为什么我一直只用它来问问题?它会让我更容易!
The forum posting rules said not to, is that incorrect? That''s why I''ve been asking questions using only pieces of it? It would make it easier for me!
哦,好点。 :呵呵:
如果你愿意,你可以把它给我。
Oh, good point. :heh:
You can PM it to me if you''d like.
这篇关于功能混乱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!