Stock Warning
#5

Quote:
Originally Posted by Gammix
Посмотреть сообщение
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.
Alright, while i was editing the loop with unreachable max value, figured out a new way. Its fixed by now.

Код:
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;
}
Reply


Messages In This Thread
Stock Warning - by Ilhan - 18.02.2016, 14:17
Re: Stock Warning - by zPain - 18.02.2016, 14:28
Re: Stock Warning - by Ilhan - 18.02.2016, 14:39
Re: Stock Warning - by Gammix - 18.02.2016, 14:43
Re: Stock Warning - by Ilhan - 18.02.2016, 14:51
Re: Stock Warning - by Nero_3D - 18.02.2016, 16:32
Re: Stock Warning - by Ilhan - 18.02.2016, 17:45

Forum Jump:


Users browsing this thread: 3 Guest(s)