Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
50
Task/Time-a-function/Aime/time-a-function.aime
Normal file
50
Task/Time-a-function/Aime/time-a-function.aime
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
integer
|
||||
identity(integer x)
|
||||
{
|
||||
x;
|
||||
}
|
||||
|
||||
|
||||
integer
|
||||
sum(integer c)
|
||||
{
|
||||
integer s;
|
||||
|
||||
s = 0;
|
||||
while (c) {
|
||||
s += c;
|
||||
c -= 1;
|
||||
}
|
||||
|
||||
s;
|
||||
}
|
||||
|
||||
|
||||
real
|
||||
time_f(integer (*fp)(integer), integer fa)
|
||||
{
|
||||
date f, s;
|
||||
time t;
|
||||
|
||||
s.now;
|
||||
|
||||
fp(fa);
|
||||
|
||||
f.now;
|
||||
|
||||
t.ddiff(f, s);
|
||||
|
||||
t.microsecond / 1000000r;
|
||||
}
|
||||
|
||||
|
||||
integer
|
||||
main(void)
|
||||
{
|
||||
o_real(6, time_f(identity, 1));
|
||||
o_text(" seconds\n");
|
||||
o_real(6, time_f(sum, 1000000));
|
||||
o_text(" seconds\n");
|
||||
|
||||
0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue