结构调整2
This commit is contained in:
27
ExampleCodes/SpeedTest/fibLoopTest.fig
Normal file
27
ExampleCodes/SpeedTest/fibLoopTest.fig
Normal file
@@ -0,0 +1,27 @@
|
||||
import std.io;
|
||||
import std.value;
|
||||
|
||||
var callCnt:Int = 0;
|
||||
func fib(x:Int) -> Int
|
||||
{
|
||||
callCnt = callCnt + 1;
|
||||
if (x <= 1)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
return fib(x-1) + fib(x-2);
|
||||
}
|
||||
|
||||
var fibx:Int;
|
||||
io.print("input an index of fib ");
|
||||
fibx = value.int_parse(io.read());
|
||||
|
||||
var cnt:Int = 0;
|
||||
io.println("test forever");
|
||||
while (true)
|
||||
{
|
||||
cnt = cnt + 1;
|
||||
io.println("test ", cnt,",result: ", fib(fibx));
|
||||
io.println("func `fib` called ", callCnt);
|
||||
callCnt = 0;
|
||||
}
|
||||
Reference in New Issue
Block a user