Just another update

This commit is contained in:
Ingy döt Net 2015-02-20 00:35:01 -05:00
parent a25938f123
commit 00a190b0a6
6591 changed files with 94363 additions and 23227 deletions

View file

@ -1 +1,4 @@
Show a loop which prints random numbers (each number newly generated each loop) from 0 to 19 (inclusive). If a number is 10, stop the loop after printing it, and do not generate any further numbers. Otherwise, generate and print a second random number before restarting the loop. If the number 10 is never generated as the first number in a loop, loop forever.
Show a loop which prints random numbers (each number newly generated each loop) from 0 to 19 (inclusive).
If a number is 10, stop the loop after printing it, and do not generate any further numbers.
Otherwise, generate and print a second random number before restarting the loop.
If the number 10 is never generated as the first number in a loop, loop forever.

View file

@ -1,4 +1,5 @@
---
category:
- Loop modifiers
- Simple
note: Iteration

View file

@ -3,4 +3,6 @@
set /a N=%RANDOM% %% 20
echo %N%
if %N%==10 exit /b
set /a N=%RANDOM% %% 20
echo %N%
goto loop

View file

@ -0,0 +1,8 @@
<Cfset randNum = 0>
<cfloop condition="randNum neq 10">
<Cfset randNum = RandRange(0, 19)>
<Cfoutput>#randNum#</Cfoutput>
<Cfif randNum eq 10><cfbreak></Cfif>
<Cfoutput>#RandRange(0, 19)#</Cfoutput>
<Br>
</cfloop>

View file

@ -0,0 +1,8 @@
while true do
(
a = random 0 19
format ("A: % \n") a
if a == 10 do exit
b = random 0 19
format ("B: % \n") b
)

View file

@ -0,0 +1,2 @@
(until (= 10 (println (rand 20)))
(println (rand 20)))

View file

@ -0,0 +1,21 @@
MODULE LoopBreak;
IMPORT
RandomNumbers,
Out;
PROCEDURE Do();
VAR
rn: LONGINT;
BEGIN
LOOP
rn := RandomNumbers.RND(20);
Out.LongInt(rn,0);Out.Ln;
IF rn = 10 THEN EXIT END;
rn := RandomNumbers.RND(20);
Out.LongInt(rn,0);Out.Ln
END
END Do;
BEGIN
Do
END LoopBreak.

View file

@ -1,7 +1,7 @@
do forever;
k = random()*19;
k = trunc(random()*20);
put (k);
if k = 10 then leave;
k = random()*19;
k = trunc(random()*20);
put skip list (k);
end;

View file

@ -0,0 +1,10 @@
loop do
a = rand(20)
print a
if a == 10
puts
break
end
b = rand(20)
puts "\t#{b}"
end

View file

@ -0,0 +1,5 @@
loop do
print a = rand(20)
puts or break if a == 10
puts "\t#{rand(20)}"
end

View file

@ -1,9 +0,0 @@
loop do
a = rand(20)
puts a
if a == 10
break
end
b = rand(20)
puts b
end

View file

@ -1,6 +1,6 @@
for(%a = 0; %a > -1; %a++)
{
%number = getRand(0, 19);
%number = getRandom(0, 19);
if(%number == 10)
break;
}