18.02.2016, 14:51
Quote:
First one appears because its a never ending loop so you'll never get to return -1.
The second one is what compiler expects to get but it doesn't know ots an infinite loop. To avoid, you'll need a limit (some max/min value) for your loop. |
Код:
stock stockname(param) { new i=1, mp=4, pp=2, total=0, re=-1; for(;;i++) { total += (i * mp) + pp; if(total >= param) { re=i;break; } } return re; }