Compare commits

...

3 Commits

Author SHA1 Message Date
Arkadiusz Hypki
c477b99571 Guess game done 2023-05-29 17:49:04 +02:00
Arkadiusz Hypki
924196de1f Merge branch 'master' of https://git.wmi.amu.edu.pl/ahypki/unixowe-systemy-operacyjne 2023-05-29 16:00:33 +02:00
Arkadiusz Hypki
c0671db3bb Statitics to all contries 2023-05-15 18:40:38 +02:00
2 changed files with 28 additions and 6 deletions

View File

@ -0,0 +1,18 @@
echo "Guess game. What is the number I'm thinking about?"
num=$(($(($RANDOM % 20))+1))
ex=1
while [ 1 -eq $ex ]
do
read usr
if [ $num == $usr ]
then
echo "Great it is $num"
ex=0
else
echo "No, it is not that number"
fi
done

View File

@ -8,12 +8,11 @@ echo "Podaj plik z danymi"
read inPlik
echo "Podaj wiek"
read inWiek
echo "Podaj kraj"
read inKraj
ile=0
wszyscy=0
declare -A kraje
# iterating line-by-line
while read line
do
@ -27,9 +26,9 @@ then
wszyscy=$((wszyscy+1))
if [ $country = "$inKraj" -a $age -ge $inWiek ]
if [ $age -ge $inWiek ]
then
ile=$((ile+1))
kraje["$country"]=$((kraje["$country"]+1))
echo "Person $name (from $country) is $age years old"
fi
@ -38,4 +37,9 @@ fi
done < $inPlik
#echo "There is $ile people from $inKraj (from all $wszyscy people)"
echo "There is `echo "scale=2; $ile/$wszyscy*100.0" | bc -l`% people from $inKraj"
#echo "There is `echo "scale=2; $ile/$wszyscy*100.0" | bc -l`% people from $inKraj"
#echo "Num of people from Poland is ${kraje["Poland"]}"
#echo "Num of people from Germany is ${kraje["Germany"]}"
for key in ${!kraje[@]}; do echo "People from $key is `echo "scale=2; ${kraje["$key"]}/$wszyscy*100.0" | bc -l`%"; done