Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- count="1"
- echo "Bienvenue sur ce programme de \"C'est plus ou c'est moins\"."
- read -p 'Entrez ici le nombre maximal à deviner. ' max_tmp
- echo "Vous venez d'entrer $max_tmp comme nombre maximal."
- if [ -z $max_tmp ] || (($max_tmp < 5)) || [[ $max_tmp = *[^0-9]* ]]
- then
- echo "Maisheu tu es pas drole TRICHEUR !"
- exit
- fi
- let "max = max_tmp + 1"
- echo "Géneration du nombre secret à deviner"
- rand=`rand -M $max`
- while true
- do
- while true
- do read -p 'Entrez un nombre ' nombre
- if [[ $max_tmp != *[^0-9]* ]]
- then break
- else
- echo "J'ai dit UN NOMBRE"
- fi
- done
- if (($nombre == $rand))
- then echo "Bravo tu as gagné"
- break
- fi
- if (($nombre < $rand))
- then let "count = count + 1"
- echo "C'est plus"
- else let "count = count + 1"
- echo "C'est moins"
- fi
- done
- echo "Tu as fait $count tentatives"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement