6 |
7u83 |
1 |
/*
|
|
|
2 |
Crown Copyright (c) 1997
|
|
|
3 |
|
|
|
4 |
This TenDRA(r) Computer Program is subject to Copyright
|
|
|
5 |
owned by the United Kingdom Secretary of State for Defence
|
|
|
6 |
acting through the Defence Evaluation and Research Agency
|
|
|
7 |
(DERA). It is made available to Recipients with a
|
|
|
8 |
royalty-free licence for its use, reproduction, transfer
|
|
|
9 |
to other parties and amendment for any purpose not excluding
|
|
|
10 |
product development provided that any such use et cetera
|
|
|
11 |
shall be deemed to be acceptance of the following conditions:-
|
|
|
12 |
|
|
|
13 |
(1) Its Recipients shall ensure that this Notice is
|
|
|
14 |
reproduced upon any copies or amended versions of it;
|
|
|
15 |
|
|
|
16 |
(2) Any amended version of it shall be clearly marked to
|
|
|
17 |
show both the nature of and the organisation responsible
|
|
|
18 |
for the relevant amendment or amendments;
|
|
|
19 |
|
|
|
20 |
(3) Its onward transfer from a recipient to another
|
|
|
21 |
party shall be deemed to be that party's acceptance of
|
|
|
22 |
these conditions;
|
|
|
23 |
|
|
|
24 |
(4) DERA gives no warranty or assurance as to its
|
|
|
25 |
quality or suitability for any purpose and DERA accepts
|
|
|
26 |
no liability whatsoever in relation to any use to which
|
|
|
27 |
it may be put.
|
|
|
28 |
*/
|
|
|
29 |
|
|
|
30 |
|
|
|
31 |
Iddec printf:proc;
|
|
|
32 |
|
|
|
33 |
String sd = "%d ";
|
|
|
34 |
String snl = "\n";
|
|
|
35 |
|
|
|
36 |
Proc generate = General Ptr Ptr Int(n:Int; ) Untidy
|
|
|
37 |
Let x = local_alloc(Sizeof(Ptr Int) .* * n)
|
|
|
38 |
Var i:Int = 0(Int)
|
|
|
39 |
Rep {
|
|
|
40 |
(x *+. (Sizeof(Ptr Int) .* * i)) =
|
|
|
41 |
local_alloc(Sizeof(Int) .* (* i + 1(Int)) );
|
|
|
42 |
i = (* i + 1(Int));
|
|
|
43 |
?(* i >= * n);
|
|
|
44 |
untidy_return(x)
|
|
|
45 |
};
|
|
|
46 |
|
|
|
47 |
Proc fill = top(a:Ptr Ptr Int, n:Int)
|
|
|
48 |
Var i:Int = 0 (Int)
|
|
|
49 |
Rep {
|
|
|
50 |
Let ai = *(Ptr Int)(* a *+. (Sizeof(Ptr Int) .* * i))
|
|
|
51 |
Var j:Int = 0(Int)
|
|
|
52 |
Rep {
|
|
|
53 |
(ai *+. (Sizeof(Int) .* * j)) = (* j + 1(Int));
|
|
|
54 |
j = (* j + 1(Int));
|
|
|
55 |
?( * j > * i);
|
|
|
56 |
};
|
|
|
57 |
i = (* i + 1(Int));
|
|
|
58 |
?(* i >= * n);
|
|
|
59 |
return(make_top)
|
|
|
60 |
};
|
|
|
61 |
|
|
|
62 |
Proc print = top(a:Ptr Ptr Int, n:Int)
|
|
|
63 |
Var i:Int = 0 (Int)
|
|
|
64 |
Rep {
|
|
|
65 |
Let ai = *(Ptr Int)(* a *+. (Sizeof(Ptr Int) .* * i))
|
|
|
66 |
Var j:Int = 0(Int)
|
|
|
67 |
Rep {
|
|
|
68 |
printf[top](sd,
|
|
|
69 |
*(Int)(ai *+. (Sizeof(Int) .* * j)));
|
|
|
70 |
j = (* j + 1(Int));
|
|
|
71 |
?( * j > * i);
|
|
|
72 |
};
|
|
|
73 |
printf[top](snl);
|
|
|
74 |
i = (* i + 1(Int));
|
|
|
75 |
?(* i >= * n);
|
|
|
76 |
return(make_top)
|
|
|
77 |
};
|
|
|
78 |
|
|
|
79 |
|
|
|
80 |
|
|
|
81 |
Proc main = top(){
|
|
|
82 |
Let a = generate[Ptr Ptr Int][ 10(Int); ]Untidy
|
|
|
83 |
{
|
|
|
84 |
fill[top](a, 10(Int));
|
|
|
85 |
print[top](a, 10(Int));
|
|
|
86 |
return(make_top)
|
|
|
87 |
}
|
|
|
88 |
};
|
|
|
89 |
|
|
|
90 |
|
|
|
91 |
Keep (main, generate)
|