LePetitGlacon

FICHE 5 BASE Exercice 2

Oct 7th, 2019
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.88 KB | None | 0 0
  1. using System;
  2.  
  3. namespace p
  4. {
  5.     class Program
  6.     {
  7.         public static void Main(string[] args)
  8.         {
  9.             Random rnd = new Random();
  10.             int nombreAleatoire = rnd.Next(0, 100);
  11.             int nombre = 0;
  12.             int compteur = 1;
  13.            
  14.             while (nombre != nombreAleatoire)
  15.             {
  16.                 Console.WriteLine("Choisissez un nombre");
  17.                 nombre = int.Parse(Console.ReadLine());
  18.                 Console.WriteLine("\n{0} essai",compteur);
  19.                
  20.                 if (nombre > nombreAleatoire)
  21.                 {
  22.                     Console.WriteLine("Le nombre est trop grand :)");
  23.                 }
  24.                 else
  25.                 {
  26.                     Console.WriteLine("Le nombre est trop petit :)");
  27.                 }
  28.                 compteur = compteur + 1;
  29.             }
  30.            
  31.             Console.WriteLine("\n\n~~~~Bien jouer tu as trouvé :))))))~~~~");
  32.             Console.ReadKey();
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment