1 Pages (6 items)
Many conditions - Messages
#1 Posted: 8/17/2021 4:30:44 AM
Здравствуйте.
Столкнулся со следующей проблемой: есть несколько условий, необходимо, чтобы при заданных значениях правильно бралось значение "а".
У меня почему-то игнорируется последнее условие - p0, то есть, в моем случае должно быть а=4, а программа выдает а=3.
Что я сделал не так?

proba.sm (11 KiB) downloaded 23 time(s).
Столкнулся со следующей проблемой: есть несколько условий, необходимо, чтобы при заданных значениях правильно бралось значение "а".
У меня почему-то игнорируется последнее условие - p0, то есть, в моем случае должно быть а=4, а программа выдает а=3.
Что я сделал не так?
proba.sm (11 KiB) downloaded 23 time(s).
#2 Posted: 8/17/2021 4:47:43 AM
I don't see error in Smath as the reports indicated in the third "If" are all verified and therefore does not even pass to the fourth "IF". Maybe you should add that P0 = 0 (or something else).
P.S. I also point out an OR in the fourth "IF" while all the others are AND: it could be an oversight
sergio
P.S. I also point out an OR in the fourth "IF" while all the others are AND: it could be an oversight
sergio
#3 Posted: 8/17/2021 4:54:56 AM
WroteI don't see error in Smath as the reports indicated in the third "If" are all verified and therefore does not even pass to the fourth "IF". Maybe you should add that P0 = 0 (or something else).
P.S. I also point out an OR in the fourth "IF" while all the others are AND: it could be an oversight
sergio
Спасибо, понял, что надо сделать - в первые три варианта прописал p0<100 и все заработало.
#4 Posted: 8/17/2021 11:30:24 AM
WroteСпасибо, понял, что надо сделать - в первые три варианта прописал p0<100 и все заработало.
You don't have to describe p<100. Just re-order the if statements.
In original, third statement if condition gets true regardless of p.0 value.
When it gets the true value in if condition, it won't be looked for next if.
Moving the p.0 boolean check to first will make all conditions available to read.
You can use cases() for smaller, tidier and much readable if blocks.
Using nested if() and cases() will reduce the huge block of boolean.
Your φ.n - λ.n - h.q checks are same for all, nesting λ under it is possible.
And you can also use multiple boolean conditions. lele(),lelt(),gege(), etc.
Regards
proba_r1.sm (5 KiB) downloaded 26 time(s).
#5 Posted: 8/18/2021 10:56:50 AM
Maths lele.sm (8 KiB) downloaded 22 time(s).
1 Pages (6 items)
-
New Posts
-
No New Posts