且构网

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

将j设置为大于-等于

更新时间:2023-02-10 15:56:02

您收到的错误是因为您实际上没有做"任何事情,只检查即可.
&gt =表示检查是否大于或等于.它不会改变j.
要增加j,您需要根据需要使用类似以下的内容.

The error you get is because you don''t actually ''do'' anything, you only check.
>= means check if greater than, or equal to. It does not change j.
To inclement j you need to use something like below, depending on what you need to do.

j = j + 1; //Add 1 to j, and store that in j
j += 1; //Add one to j, and store it in j (shorthand notation)
j++; //Increment j with 1 (even shorter shorthand notation)

//Or with n

j += n; //Add n to j, and store in j(same as j = j + n)
j *= n; //Multiply j with n, and store in j (same as j = j * n)



希望这对您有所帮助,如果没有,请随时发表评论.



Hope this helps you on your way, if not, feel free to post a comment.


错误消息很清楚:
The error message is clear:
j >= j * n;


不是有效的声明.
您正在尝试做什么(您知道,您可以只使用(有效)语句


is NOT a valid statement.
What are you trying to do (you know, you may just use the (valid) statement

j++;


用于递增j).


顺便说一句,没有 设置j大于或等于i" ,但只有 测试j是否大于或等于i" (至少在我所知道的编程语言中).


for incrementing j).


BTW there is NO "setting j greater than or equal to i", but only "testing if j is greater or equal to i" (at least in the programming languages I know).


前面已经说过,j >= j * n严格等同于n <= 1 || j == 0,它更有效,因为第二部分在大多数情况下可能不被检查或不需要包含在表达式中,因为第二部分在代码中是这样定义的. >
—SA
In addition to what was already said, j >= j * n is strictly equivalent to n <= 1 || j == 0, which is more effective because the second part may not be checked in most cases or need not to be included in the expression because it is so defined in code.

—SA