代码的优化 [英] Optimalization of the code

查看:106
本文介绍了代码的优化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在我的学校项目上工作了两个星期,现在它终于完成了,它运作正常。但是存在一个很大的问题 - 它太长了。我做得尽可能短,但还不够。它必须最多220线,现在我的线路超过300线。有人可以帮助我缩短我的代码吗?您可以进行任何必要的更改 - 删除内容,添加内容,任何内容。它必须像现在一样正常工作。



我非常感谢你的帮助。



由于代码很长,我在这里贴了它:https://codeshare.io/GbP4wq还有任务。



谢谢你帮助。



如果你有什么不明白的话,我非常抱歉。我尽力翻译它。



我尝试过:



根据我的知识,我不知道我还能做什么

I have been working on my school project for 2 weeks and now it is finally done and it works properly. But there is a big problem - it is way too long. I made it as short as possible but it is not enough. It has to be max 220 lines long and mine now has more than 300 lines. Can someone help me make my code shorter? You can make any neccesary changes - delete something, add something, anything. It just has to work properly like it does now.

I would be very thankful for your help.

Since the code is very long, I have pasted it here: https://codeshare.io/GbP4wq There is also the task.

Thank you for any help.

I very very apologize if there is something that you do not understand. I tried to translate it the best I could.

What I have tried:

Everything in my knowledge, I have no idea what else can I do

推荐答案

抱歉,但没有。

我们这样做不做你的功课:这是有原因的。它就是为了让你思考你被告知的事情,并试着理解它。它也在那里,以便您的导师可以识别您身体虚弱的区域,并将更多的注意力集中在补救措施上。

如果您的任务的一部分是生成某个最大长度的代码,那么那就是你应该做的工作的一部分 - 我们为你做这件事对同班同学中的其他人来说是不公平的。



亲自尝试,你可能会发现它并不像你想象的那么困难!

首先查找公共代码,然后将其抽象为函数或#define's。

寻找冗余;考虑一下代码是做什么的,如果有一个更好的方法就可以解决问题。如果您的要求是最多220行,那么我猜老师希望大多数学生大约一半...



如果您遇到特定问题,那么请询问这一点,我们将尽力提供帮助。但我们不打算为你做这一切!
Sorry, but no.
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.
If part of your task is to produce code of a certain maximum length, then that is part of the job you are supposed to do - our doing it for you would be unfair on the others in your class with the same task.

Try it yourself, you may find it is not as difficult as you think!
Start by looking for common code, and abstracting it to functions or #define's.
Look for redundancy; think about what code is doing and work out if there is a "better way". If your requirement is 220 lines max, then I'm guessing the teacher expects around half that from most students...

If you meet a specific problem, then please ask about that and we will do our best to help. But we aren't going to do it all for you!


这篇关于代码的优化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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