Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.89 KB | None | 0 0
  1. #!/bin/bash
  2. count="1"
  3.         echo "Bienvenue sur ce programme de \"C'est plus ou c'est moins\"."
  4. read -p 'Entrez ici le nombre maximal à deviner. ' max_tmp
  5.         echo "Vous venez d'entrer $max_tmp comme nombre maximal."
  6. if [ -z $max_tmp ] || (($max_tmp < 5)) || [[ $max_tmp = *[^0-9]* ]]
  7. then
  8. echo "Maisheu tu es pas drole TRICHEUR !"
  9. exit
  10. fi
  11. let "max = max_tmp + 1"
  12.         echo "Géneration du nombre secret à deviner"
  13. rand=`rand -M $max`
  14. while true
  15. do
  16.         while true
  17.         do      read -p 'Entrez un nombre ' nombre
  18.         if [[ $max_tmp != *[^0-9]* ]]
  19.         then break
  20.         else
  21.         echo "J'ai dit UN NOMBRE"
  22.         fi
  23. done
  24. if (($nombre == $rand))
  25. then echo "Bravo tu as gagné"
  26. break
  27. fi
  28. if (($nombre < $rand))
  29. then let "count = count + 1"
  30. echo "C'est plus"
  31. else let "count = count + 1"
  32. echo "C'est moins"
  33. fi
  34. done
  35. echo "Tu as fait $count tentatives"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement