Hra na hádanie čísla

Delphi & Pascal (česká wiki)
Přejít na: navigace, hledání
Kategorija: KMP (Programy mladňakoch
myslim_c.pngProgram: Myslim_c.pas
Subor exe: Myslim_c.exe

Hra na hádanie čísla
{ MYSLIM_C.PAS                                                      }
{ Hra s jednoduchym menu.                                           }
{                                                                   }
{ Author: Unknown                                                   }
{ Datum: 26.11.2010                            http://www.trsek.com }
 
program myslim;
uses crt;
var a,b,c,d,e,r,pokr,u:longint;
    h1,h2,h3:string;
    x,w:char;
procedure hra;
begin
     clrscr;
     textcolor(15);writeln('Hrac 1, ako sa volas?');
     readln(h1);
     writeln('');
     writeln('Hrac 2, ako sa volas?');
     readln(h2);
     writeln('');
     writeln('Hrac 3, ako sa volas?');
     readln(h3);
     writeln('');
     writeln('Tato hra nieje tazka. ',h3,' si bude mysliet cele cislo.');
     writeln('',h1,' a ',h2,' budu typovat. Koho typ bude blizsie,  vyhrava.');
     writeln('Cisla budu ciernou farbou.');
     writeln('');
     writeln('',h3,', napis cislo ktore budu ',h1,' a ',h2,' hadat.');
     textcolor(0);readln(r);
     textcolor(15);writeln('',h1,', typni si, ake cislo si ',h3,' mysli?:');
     textcolor(0);readln(a);
     textcolor(15);writeln('',h2,', aky je tvoj typ?');
     textcolor(0);readln(b);
     c:=r-a;
     d:=r-b;
     textcolor(10);if(c<d)then writeln('',h1,' vyhral!');
     if(d<c)then writeln('',h2,' vyhral!');
     if(a=r)then writeln('',h1,' trafil cislo!');
     if(b=r)then writeln('',h2,' trafil cislo!');
     if(a=b)then writeln('',h1,' aj ',h2,' tipli rovnake cislo');
     writeln('',h3,' si myslel cislo ',r,'.');
     writeln('',h1,' si typol cislo ',a,'.');
     writeln('',h2,' si typol cislo ',b,'.');
     textcolor(15);writeln('Michal Szabo 2010');
     readln;
     writeln('Hrat znovu?  a/n');
     w:=readkey;
     if(w='a')then begin
             hra;
         end;
     if(w='n')then
     end;
 
procedure instr;
begin
clrscr;
GotoXY(10,10);textcolor(15);writeln('Tato hra nieje tazka. Jeden hrac si bude mysliet');
writeln('cislo a dalsi dvaja ho budu hadat.Cisla budu ciernou farbou. Za kazdim');
writeln('zadanim udajom stlacte ENTER. Pre zacatie hry stacte ENTER.');
writeln('Michal Szabo 2010');
readln;
u:=1;
if(u=1)then begin
     hra;
  end;
end;
 
begin
     clrscr;
     textcolor(9);GotoXY(35,11);writeln('Nacitavam');
     write('....................');
     write('..............................');
     writeln('..............................');
     GotoXY(35,15);writeln('Stlac ENTER');
     readln;
     clrscr;
     Writeln('                           Myslim si ');
     writeln('                ###   ###  ###    #       ###   ');
     writeln('               #   #   #  #   #   #      #   #  ');
     writeln('               #       #  #       #      #   #  ');
     writeln('               #       #   ###    #      #   #  ');
     writeln('               #       #      #   #      #   #  ');
     writeln('               #   #   #  #   #   #      #   #  ');
     writeln('                ###   ###  ###    #####   ###   ');
     writeln;
     writeln('                        Stlac ENTER');
     readln;
     writeln;
     textcolor(15);writeln('Menu:   h  -  Hra');
     writeln('        i  -  Instrukcie');
     writeln('        k  -  Koniec');
     x:=readkey;
     if(x='h')then begin
             hra;
         end;
     if(x='i')then begin
            instr;
         end;
     if(x='k')then
end.