-
Notifications
You must be signed in to change notification settings - Fork 15
/
gera-entrada
65 lines (59 loc) · 1.36 KB
/
gera-entrada
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash
# Copyright(C) 2020, Bruno César Ribas <bruno.ribas@unb.br>
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of version 2.1 of the GNU Lesser General Public License
# as published by the Free Software Foundation.
#
# This program is distributed in the hope that it would be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
function ordenado()
{
local size=$1
echo $size
shuf -i0-$((size*2)) -n $size|sort -n
}
function reverso()
{
local size=$1
echo $size
shuf -i0-$((size*2)) -n $size|sort -n -r
}
function aleatorio()
{
local size=$1
echo $size
shuf -i0-$((size*2)) -n $size
}
function quaseordenado()
{
local size=$1
local V=(`eval echo {0..$size}`)
local tochange=$((size/10/2))
for((i=0;i<tochange;i++)); do
T=$((RANDOM%size))
T2=$((RANDOM%size))
x=${V[$T]}
V[$T]=${V[$T2]}
V[$T2]=$x
done
echo $size
echo ${V[@]}|tr ' ' '\n'
}
function muitosrepetidos()
{
local size=$1
echo $size
shuf -r -i0-$((size/3)) -n $size|sort -n -r
}
for((i=8;i<=20;i++)); do
tam=$((1<<i))
k=$(printf "%02d" $i)
ordenado $tam > $k-ordenado &
reverso $tam > $k-reverso &
aleatorio $tam > $k-aleatorio &
quaseordenado $tam > $k-quaseordenado &
muitosrepetidos $tam > $k-muitosrepetidos &
done
wait