Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program zgadywanka3;
- uses Crt;
- var
- liczba: integer;
- liczbaGracza: integer;
- przedzial: integer;
- liczbaProb: integer;
- dzialanie: boolean;
- procedure policzProby(a:integer);
- begin
- if a = 9 then
- begin
- Writeln('Skoczyly Ci sie proby, przegrales.');
- dzialanie:= false;
- end
- end;
- function sprawdzLiczbe(a,b:integer):string;
- begin
- if a > b then
- begin
- Result:='Podana liczba jest za duza';
- Inc(liczbaProb);
- end;
- if a < b then
- begin
- Result:='Podana liczba jest za mala';
- Inc(liczbaProb);
- end;
- if a = b then
- begin
- Result:='Brawo ! To jest ta liczba!';
- Inc(liczbaProb);
- dzialanie:= false;
- end;
- end;
- function ustalPrzedzial(a:integer):integer;
- begin
- randomize;
- case a of
- 1:
- Result:=random(11);
- 2:
- Result:=random(21);
- 3:
- Result:=random(31);
- end;
- end;
- begin
- liczbaProb:=0;
- dzialanie:= true;
- Writeln('Witam w zgadywance liczbowej! Program wlasnie wylosowal liczbe z wybranego przez Ciebie przedzialo.');
- Writeln('Twoim zadaniem jest odgadnac ta liczbe w 10 probach na podstawie wskazowek podanych przez komputer.');
- Writeln('Podaj z jakiego przedzialu chcesz zgadywac liczbe:');
- Writeln('1. 1-10');
- Writeln('2. 1-20');
- Writeln('3. 1-30');
- read(przedzial);
- liczba:=ustalPrzedzial(przedzial);
- repeat
- Writeln('Liczba prob: ', liczbaProb);
- Writeln('Podaj liczbe: ');
- read(liczbaGracza);
- policzProby(liczbaProb);
- writeln(sprawdzLiczbe(liczbaGracza,liczba));
- until dzialanie = false;
- readkey;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement