Guest User

Untitled

a guest
Apr 25th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.61 KB | None | 0 0
  1. using System;
  2.  
  3. class Program
  4. {
  5.     public static void Main()
  6.     {
  7.         Random r = new Random();
  8.        
  9.         int titok = r.Next(1, 101), get = 0, proba = 0;
  10.        
  11.        
  12.         while( get != titok && proba < 5 )
  13.         {
  14.             Console.Write("\nSzám: ");
  15.             get = int.Parse(Console.ReadLine());
  16.            
  17.             if( get > titok )
  18.             {
  19.                 Console.WriteLine("Kisebb");
  20.             }
  21.             else if( get < titok )
  22.             {
  23.                 Console.WriteLine("Nagyobb");
  24.             }
  25.             else if( get == titok )
  26.             {
  27.                 Console.WriteLine("Eltaláltad!!");
  28.                 break;
  29.             }
  30.            
  31.             proba++;
  32.         }
  33.        
  34.         Console.WriteLine("\n\nNem sikerült! :(");
  35.        
  36.         Console.ReadKey(true);
  37.     }
  38. }
Add Comment
Please, Sign In to add comment