Just another update
This commit is contained in:
parent
a25938f123
commit
00a190b0a6
6591 changed files with 94363 additions and 23227 deletions
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
---
|
||||
category:
|
||||
- Loop modifiers
|
||||
- Simple
|
||||
note: Iteration
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
8
Task/Loops-Break/ColdFusion/loops-break.cfm
Normal file
8
Task/Loops-Break/ColdFusion/loops-break.cfm
Normal 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>
|
||||
8
Task/Loops-Break/MAXScript/loops-break.max
Normal file
8
Task/Loops-Break/MAXScript/loops-break.max
Normal 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
|
||||
)
|
||||
2
Task/Loops-Break/NewLISP/loops-break.newlisp
Normal file
2
Task/Loops-Break/NewLISP/loops-break.newlisp
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
(until (= 10 (println (rand 20)))
|
||||
(println (rand 20)))
|
||||
21
Task/Loops-Break/Oberon-2/loops-break.oberon-2
Normal file
21
Task/Loops-Break/Oberon-2/loops-break.oberon-2
Normal 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.
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
10
Task/Loops-Break/Ruby/loops-break-1.rb
Normal file
10
Task/Loops-Break/Ruby/loops-break-1.rb
Normal 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
|
||||
5
Task/Loops-Break/Ruby/loops-break-2.rb
Normal file
5
Task/Loops-Break/Ruby/loops-break-2.rb
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
loop do
|
||||
print a = rand(20)
|
||||
puts or break if a == 10
|
||||
puts "\t#{rand(20)}"
|
||||
end
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
loop do
|
||||
a = rand(20)
|
||||
puts a
|
||||
if a == 10
|
||||
break
|
||||
end
|
||||
b = rand(20)
|
||||
puts b
|
||||
end
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
for(%a = 0; %a > -1; %a++)
|
||||
{
|
||||
%number = getRand(0, 19);
|
||||
%number = getRandom(0, 19);
|
||||
if(%number == 10)
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue