% $Id: ackermann.cim,v 1.2 2002/05/16 15:30:00 dada Exp $
external class UNIX;
begin
integer procedure Ack(m, n); integer m, n;
begin
if m = 0 then Ack := n + 1
else if n = 0 then Ack := Ack(m-1, 1)
else Ack := Ack(m-1, Ack(m, n-1));
end;
integer i;
text t;
t :- Blanks(80);
t := Arg(1);
comment OutInt(Argc, 4);
comment OutText(Arg(1));
i := t.getInt;
if i < 1 then i := 1;
OutText("Ack(3,");
OutInt(i, 0);
OutText("): ");
OutInt(Ack(3, i), 0);
OutImage;
end
|
% $Id: fibo.cim,v 1.2 2002/05/16 15:28:00 dada Exp $
external class UNIX;
begin
integer procedure fib(n); integer n;
begin
if n < 2 then fib := 1
else fib := fib(n-2) + fib(n-1);
end;
integer i;
text t;
t :- Blanks(80);
t := Arg(1);
comment OutInt(Argc, 4);
comment OutText(Arg(1));
i := t.getInt;
if i < 1 then i := 1;
OutInt(fib(i),0);
OutImage;
end
|
% $Id: nestedloop.cim,v 1.0 2002/11/07 15:47:00 dada Exp $
external class UNIX;
begin
integer n, a, b, c, d, e, f, x;
text t;
t :- Blanks(80);
t := Arg(1);
n := t.getInt;
if n < 1 then n := 1;
For a := 1 step 1 until n do
For b := 1 step 1 until n do
For c := 1 step 1 until n do
For d := 1 step 1 until n do
For e := 1 step 1 until n do
For f := 1 step 1 until n do
x := x + 1;
OutInt(x,0);
OutImage;
end
|
% $Id: sumcol.cim,v 1.0 2002/10/29 13:41:00 dada Exp $
external class UNIX;
begin
integer i, tot;
inspect SysIn do
while not SysIn.LastItem do
begin
i := InInt;
tot := tot + i;
end;
OutInt(tot, 0);
OutImage;
end
|