Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace cheroke_Pinna
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13.  
  14. int su=0, ru, cn, conta=0; // su scelta utente / cn casual number
  15.  
  16. do
  17. {
  18. conta = 0;
  19. Random r = new Random();
  20. cn = r.Next(1, 11);
  21.  
  22. Console.WriteLine("prova a indovinare il mio numero da 1 a 10, però hai solo 3 tentativi");
  23. Console.WriteLine("il numero è " + cn);
  24. do
  25. {
  26. su = Convert.ToInt16(Console.ReadLine());
  27. if (su == cn)
  28. {
  29. conta = 5;
  30. }
  31. else
  32. {
  33. conta++;
  34. if (su < cn)
  35. {
  36. Console.WriteLine("il numero da indovinare è più grande");
  37. }
  38. else
  39. {
  40. Console.WriteLine("il numero da indovinare è più piccolo");
  41. }
  42. }
  43. }
  44. while (conta < 3);
  45. if (conta == 3)
  46. {
  47. Console.WriteLine("Hai Perso");
  48. }
  49. else
  50. {
  51. Console.WriteLine("Hai Vinto");
  52. }
  53. Console.WriteLine("vuoi continuare? scrivi s se vuoi continuare, sennò premi invio");
  54. ru=Convert.ToChar(Console.ReadLine());
  55. }
  56. while(ru=='s');
  57.  
  58. Console.ReadLine();
  59.  
  60. }
  61. }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement