2016 Update
This commit is contained in:
parent
948b86eafa
commit
dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions
|
|
@ -2,7 +2,7 @@ with Ada.Text_IO; use Ada.Text_IO;
|
|||
with Ada.Numerics.Discrete_Random;
|
||||
|
||||
procedure Test_Loop_Break is
|
||||
type Value_Type is range 1..20;
|
||||
type Value_Type is range 0..19;
|
||||
package Random_Values is new Ada.Numerics.Discrete_Random (Value_Type);
|
||||
use Random_Values;
|
||||
Dice : Generator;
|
||||
|
|
|
|||
5
Task/Loops-Break/BASIC/loops-break-3.basic
Normal file
5
Task/Loops-Break/BASIC/loops-break-3.basic
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
10 LET a = INT (RND * 20)
|
||||
20 PRINT a
|
||||
30 IF a = 10 THEN STOP
|
||||
40 PRINT INT (RND * 20)
|
||||
50 GO TO 10
|
||||
|
|
@ -2,16 +2,16 @@
|
|||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main() {
|
||||
int a, b;
|
||||
#define LOWER 0
|
||||
#define UPPER 19
|
||||
|
||||
int main() {
|
||||
srand(time(NULL));
|
||||
while (1) {
|
||||
a = rand() % 20; /* not exactly uniformly distributed, but doesn't matter */
|
||||
|
||||
for (;;) {
|
||||
unsigned a = LOWER + rand() / (RAND_MAX / (UPPER - LOWER + 1) + 1);
|
||||
printf("%d\n", a);
|
||||
if (a == 10) break;
|
||||
b = rand() % 20; /* not exactly uniformly distributed, but doesn't matter */
|
||||
printf("%d\n", b);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
4
Task/Loops-Break/CoffeeScript/loops-break.coffee
Normal file
4
Task/Loops-Break/CoffeeScript/loops-break.coffee
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
loop
|
||||
print a = Math.random() * 20 // 1
|
||||
break if a == 10
|
||||
print Math.random() * 20 // 1
|
||||
|
|
@ -1,7 +1,4 @@
|
|||
(loop
|
||||
(setq a (random 20))
|
||||
(print a)
|
||||
(if (= a 10)
|
||||
(return))
|
||||
(setq b (random 20))
|
||||
(print b))
|
||||
(loop for a = (random 20)
|
||||
do (print a)
|
||||
until (= a 10)
|
||||
do (print (random 20)))
|
||||
|
|
|
|||
|
|
@ -1,15 +1,13 @@
|
|||
defmodule Loops do
|
||||
def break do
|
||||
:random.seed(:os.timestamp)
|
||||
break(:random.uniform(20)-1)
|
||||
def break, do: break(random)
|
||||
|
||||
defp break(10), do: IO.puts 10
|
||||
defp break(r) do
|
||||
IO.puts "#{r},\t#{random}"
|
||||
break(random)
|
||||
end
|
||||
|
||||
def break(10), do: IO.puts 10
|
||||
def break(r) do
|
||||
IO.write r
|
||||
IO.puts ",\t#{:random.uniform(20)-1}"
|
||||
break(:random.uniform(20)-1)
|
||||
end
|
||||
defp random, do: Enum.random(0..19)
|
||||
end
|
||||
|
||||
Loops.break
|
||||
|
|
|
|||
7
Task/Loops-Break/Io/loops-break.io
Normal file
7
Task/Loops-Break/Io/loops-break.io
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
loop(
|
||||
a := Random value(0,20) floor
|
||||
write(a)
|
||||
if( a == 10, writeln ; break)
|
||||
b := Random value(0,20) floor
|
||||
writeln(" ",b)
|
||||
)
|
||||
|
|
@ -1,34 +1,14 @@
|
|||
18
|
||||
10
|
||||
16
|
||||
10
|
||||
8
|
||||
0
|
||||
13
|
||||
3
|
||||
2
|
||||
14
|
||||
15
|
||||
17
|
||||
14
|
||||
7
|
||||
10
|
||||
8
|
||||
0
|
||||
2
|
||||
0
|
||||
2
|
||||
5
|
||||
16
|
||||
3
|
||||
16
|
||||
6
|
||||
7
|
||||
19
|
||||
0
|
||||
16
|
||||
9
|
||||
7
|
||||
11
|
||||
17
|
||||
10
|
||||
console.log(
|
||||
(function streamTillInitialTen() {
|
||||
var nFirst = Math.floor(Math.random() * 20);
|
||||
|
||||
if (nFirst === 10) return [10];
|
||||
|
||||
return [
|
||||
nFirst,
|
||||
Math.floor(Math.random() * 20)
|
||||
].concat(
|
||||
streamTillInitialTen()
|
||||
);
|
||||
})().join('\n')
|
||||
);
|
||||
|
|
|
|||
11
Task/Loops-Break/Kotlin/loops-break.kotlin
Normal file
11
Task/Loops-Break/Kotlin/loops-break.kotlin
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
import java.util.Random
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val rand = Random()
|
||||
while (true) {
|
||||
val a = rand.nextInt(20)
|
||||
println(a)
|
||||
if (a == 10) break
|
||||
println(rand.nextInt(20))
|
||||
}
|
||||
}
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
import random
|
||||
from random import randrange
|
||||
|
||||
while True:
|
||||
a = random.randrange(20)
|
||||
print a
|
||||
a = randrange(20)
|
||||
print(a)
|
||||
if a == 10:
|
||||
break
|
||||
b = random.randrange(20)
|
||||
print b
|
||||
b = randrange(20)
|
||||
print(b)
|
||||
|
|
|
|||
|
|
@ -1,15 +1,14 @@
|
|||
use rand::Rng;
|
||||
// cargo-deps: rand
|
||||
|
||||
extern crate rand;
|
||||
use rand::distributions::{Range, IndependentSample};
|
||||
|
||||
fn main() {
|
||||
let mut rng = rand::thread_rng();
|
||||
loop {
|
||||
let num = rng.gen_range(0, 20);
|
||||
println!("{}", num);
|
||||
let num = Range::new(0, 19 + 1).ind_sample(&mut rand::thread_rng());
|
||||
if num == 10 {
|
||||
println!("{}", num);
|
||||
break;
|
||||
}
|
||||
println!("{}", rng.gen_range(0, 20));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue