all tasks
This commit is contained in:
parent
b83f433714
commit
68f8f3e56b
14735 changed files with 178959 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)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
integer
|
||||
sum(integer c)
|
||||
{
|
||||
integer s;
|
||||
|
||||
s = 0;
|
||||
while (c) {
|
||||
s += c;
|
||||
c -= 1;
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
real
|
||||
time_f(integer (*fp) (integer), integer fa)
|
||||
{
|
||||
date f, s;
|
||||
time t;
|
||||
|
||||
d_now(s);
|
||||
|
||||
fp(fa);
|
||||
|
||||
d_now(f);
|
||||
|
||||
t_ddiff(t, f, s);
|
||||
|
||||
return t_microsecond(t) / 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");
|
||||
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue