Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
32
Task/Loops-Wrong-ranges/XPL0/loops-wrong-ranges.xpl0
Normal file
32
Task/Loops-Wrong-ranges/XPL0/loops-wrong-ranges.xpl0
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
include xpllib; \for Print
|
||||
|
||||
def \S\ Start, Stop, Incr, Comment;
|
||||
int S, Examples, I, J, C, Empty;
|
||||
def Limit = 10;
|
||||
[Examples:= [
|
||||
[-2, 2, 1, "Normal"],
|
||||
[-2, 2, 0, "Zero increment"],
|
||||
[-2, 2, -1, "Increments away from stop value"],
|
||||
[-2, 2, 10, "First increment is beyond stop value"],
|
||||
[2, -2, 1, "Start more than stop: positive increment"],
|
||||
[2, 2, 1, "Start equal stop: positive increment"],
|
||||
[2, 2, -1, "Start equal stop: negative increment"],
|
||||
[2, 2, 0, "Start equal stop: zero increment"],
|
||||
[0, 0, 0, "Start equal stop equal zero: zero increment"]
|
||||
];
|
||||
for I:= 0 to 9-1 do
|
||||
[S:= Examples(I);
|
||||
Print("%s\n", S(Comment));
|
||||
Print("Range(%d, %d, %d) -> [", S(Start), S(Stop), S(Incr));
|
||||
Empty:= true;
|
||||
\\ for (j:= s.start, c:= 0; j <= s.stop && c < limit; j += s.incr, ++c)
|
||||
J:= S(Start); C:= 0;
|
||||
while J <= S(Stop) and C < Limit do
|
||||
[Print("%d ", J);
|
||||
Empty:= false;
|
||||
J:= J + S(Incr); C:= C+1;
|
||||
];
|
||||
if not Empty then ChOut(0, $08 \BS\);
|
||||
Print("]\n\n");
|
||||
]
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue