且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

找到第一个和第二个元素== 0和之间的总和

更新时间:2023-02-06 19:15:31

引用:

我现在有这样的代码,但它根本不起作用。

I have code like this right now, but it doesnt work at all.



好​​吧,不。它不会。

它甚至不会编译,更不用说运行或做任何有用的事情。



扔掉那么多,从头开始。

在简单阶段中执行。

编写一个函数来查找前0值,并返回它的索引。

当有效时,将其更改为找到第一个和第二个零值。

当有效时,添加代码以对它们之间的值求和。



但是......这是你的作业,所以我不会给你任何代码:它很简单,如果你在简单的阶段做到这一点,并在每次启动代码之前思考,你会在很少的时候做到这一点时间。


Well, no. It won't.
It won't even compile, much less run or do anything useful.

Throw that lot away, and start again from scratch.
Do it in "easy stages".
Write a function to find the first 0 value, and return it's index.
When that works, change it to find the first and second zero value.
When that works, add the code to sum the values between them.

But ... this is your homework, so I'll give you no code: it simple enough that if you do it in easy stages and think before you start code each time, you will do it in very little time at all.