Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
RandomNumber - RandomNumber.PAS

RandomNumber.PAS

Caricato da: Progman-92
Scarica il programma completo

  1. program GiocoNumeri;
  2. uses crt;
  3. var a,b,c,z,risp1,risp2,risp3,risp4,rispPos: integer;
  4. begin
  5. randomize;
  6. repeat
  7. repeat
  8. clrscr;
  9. textcolor(lightgreen);
  10. gotoxy(6,2);
  11. writeln('Semplice gioco che coniste nell''indovinare il numero che pensa il PC');
  12. textcolor(lightmagenta);
  13. writeln;
  14. writeln;
  15. write('Scegli il livello (1=Numeri da 1 a 10, 2=Numeri da 1 a 20, 3=Numeri da 1 a 30) =');
  16. readln(risp1);
  17. if risp1 > 3 then
  18.    begin
  19.     textcolor(lightred);
  20.     write('Errore di inserimento dati!!! Scegliere un valore compreso tra 1 e 3');
  21.    end;
  22. until
  23. risp1 <= 3;
  24. writeln;
  25. write('Scegli il numero di tentativi di risposta che puoi dare al massimo=');
  26. readln(risp2);
  27. writeln;
  28. for z:= 1 to 80 do write(char(205));
  29. risp3:=risp2+1;
  30. if risp1 = 1 then
  31.   begin
  32.    a:=random(10);
  33.   end;
  34. if risp1 = 2 then
  35.   begin
  36.    a:=random(20);
  37.   end;
  38. if risp1 = 3 then
  39.  begin
  40.   a:=random(30);
  41.  end;
  42. writeln;
  43. c:=1;
  44. repeat
  45. begin
  46. writeln;
  47. writeln('Scrivi il numero che tu presupponi io pensi');
  48. readln(b);
  49. if b > a then
  50.   begin
  51.    textcolor(lightred);
  52.    writeln('Numero troppo grande');
  53.    sound(4000);
  54.    delay(200);
  55.    sound(3000);
  56.    delay(150);
  57.    sound(2000);
  58.    delay(100);
  59.    nosound;
  60.    textcolor(lightmagenta);
  61.   end;
  62. if a > b then
  63.   begin
  64.    textcolor(lightred);
  65.    writeln('Numero troppo piccolo');
  66.    sound(2000);
  67.    delay(100);
  68.    sound(3000);
  69.    delay(150);
  70.    sound(4000);
  71.    delay(200);
  72.    nosound;
  73.    textcolor(lightmagenta);
  74.   end;
  75. if a = b then
  76.   begin
  77.    rispPos:=1;
  78.    textcolor(lightgreen);
  79.    writeln('Hai indovinato bravo');
  80.    sound(2000);
  81.    delay(100);
  82.    sound(3000);
  83.    delay(150);
  84.    sound(4000);
  85.    delay(200);
  86.    nosound;
  87.   end;
  88.   c:=c+1;
  89. end;
  90. until
  91. (c = risp3) or (rispPos = 1);
  92. writeln;
  93. textcolor(lightblue);
  94. writeln('Il numero che io avevo pensato era ',a);
  95. textcolor(yellow);
  96. writeln;
  97. writeln;
  98. writeln;
  99. write('Premere 1 per continuare, 0 per uscire=');
  100. readln(risp4);
  101. until risp4=0
  102. end.