Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
29
Task/Loops-Break/Sather/loops-break.sa
Normal file
29
Task/Loops-Break/Sather/loops-break.sa
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
-- help class for random number sequence
|
||||
class RANDOM is
|
||||
attr seed:INT;
|
||||
|
||||
create(seed:INT):SAME is
|
||||
res:RANDOM := new;
|
||||
res.seed := seed;
|
||||
return res;
|
||||
end;
|
||||
-- this code is taken from rand's man (C)
|
||||
next:INT is
|
||||
seed := seed * 1103515245 + 12345;
|
||||
return (seed/65536) % 32768;
|
||||
end;
|
||||
end;
|
||||
|
||||
class MAIN is
|
||||
main is
|
||||
a, b :INT;
|
||||
rnd:RANDOM := #(1);
|
||||
loop
|
||||
a := rnd.next % 20;
|
||||
#OUT + a + "\n";
|
||||
if a = 10 then break!; end; -- here we break
|
||||
b := rnd.next % 20;
|
||||
#OUT + b + "\n";
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
Loading…
Add table
Add a link
Reference in a new issue