{Vzorová øešení - Pøíklady pro zaèáteèníky II}

Program Vtip;
{Vypise na obrazovku nahodny vtip}
Begin
   Randomize;
   Case Random(5) of
     0:Writeln('Na zene kulturistce jsou uz jen plavky naozaj zenske.');
     1:Writeln('Sli dva medvedi, jeden hnedy a druhy doprava.');
     2:Writeln('Nehazej me do te sachtyachtyachtyachty.');
     3:Writeln('Vis, co je to veletrh? Kdyz si pri prelezani plotu natrhnes kalhoty aj kuzi.');
     4:begin
         Writeln('Pri tanecni zabave:');
         Writeln('S tou nadhernou kockou jsem pred chvili tancil valcik.');
         Writeln('Ale vzdyt to byla polka!');
         Writeln('Polka? Vzdyt mluvila uplne perfektne cesky.');
       end;
   end;
   Readln;
End.

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Program AhojVsude;
{Zaplni celou obrazovku nesmyslnym napisem}
Var I:Integer;
Begin
 Writeln('Cauves');
 For I:=1 to 980 do
  Write('Ahoj');
 Readln;
End.

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Program NahodneZnaky;
{Udela na obrazovce peknej brajgl a pote pocka na stisk entru}
Uses Crt;
Begin
ClrScr;
Randomize;
 Repeat
   TextColor(Random(17));
   Write(Chr(Random(256)));
 Until Random(1000)=917;
Readln;
End.

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Program SeradDveCisla;
{Seradi dve cisla podle velikosti}
Var A,B,C : Integer;
Begin
 Write('Zadej dve cisla a,b : ');
 Readln(A,B);
 if A > B then
  begin
   C:=A; {Prohodime A a B pomoci pomocne promenne}
   A:=B;
   B:=C;
  end;
 Writeln; {Kvuli prehlednosti}
 Writeln(A, ' je mensi nebo rovno ',B);
 Readln;
End.

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Program Sirena;
{Mela by pistet, ale vzhledem ke kvalite dnesnich speakru...}
Uses Crt;
Var Frekvence : Integer;
Begin
 For Frekvence:=37 to 30000 do
    Begin
       Sound(Frekvence);
    End;
 For Frekvence:=37 to 30000 do
    Begin
       Sound(30037-Frekvence);
    End;
End.

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Program PromenneAhoj;
Uses Crt;
Begin
 TextBackground(1); {Nahodne barvy pusobi hnusne}
 ClrScr;
 Repeat
  GotoXY(Random(77)+1,Random(49)+1); {Nahodne misto obrazovky, pozor na kraje!!!}

  TextColor(Random(17));
  Write('A');
  TextColor(Random(17));
  Write('h');
  TextColor(Random(17));
  Write('o');
  TextColor(Random(17));
  Write('j');
 until KeyPressed; {- dokud neni stisknuta nejaka klavesa}

 {Nastal cas na uklid}
 TextBackground(0);
 TextColor(7);
 ClrScr;
End.

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Program Retezce;
{Porovna dva retezce podle abecedy}
Var R1,R2 : string;
Begin
 Writeln('Zadej dva retezce (malymi pismeny): '); {Vsechna velka pismena jsou v ASCII pred malymi!!!}
 Readln(R1);
 Readln(R2);
 Writeln;
 If R1 < R2 then Writeln('''',R1,''' stoji v abecede pred ''', R2,''''); {aneb jak se pisi apostrofy}
 If R1 = R2 then Writeln('Oba retezce jsou identicke');
 If R1 > R2 then Writeln('"',R2,'" stoji v abeceda pred "',R1,'"');
 Readln;
End.

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Program Pythagoras;
{Vypise vsechna reseni a2+b2=c2 na obrazovku (a,b,c <100);}
Var A,B,C : Integer;
Begin
 For A:=1 to 100 do
  For B:=1 to 100 do
   For C:=1 to 100 do
    if A*A +B*B = C*C then Write(a:3,' ',b:3,' ',c:4,'        ');
    {Ta mezera je tam kvuli uprave, write aby se vsechno veslo na obrazovku}
Readln;
End.

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Program Deleni;
{Vydeli dve cisla zadana uzivatelem}
Var A,B : Integer;
      C : Real; {Vysledkem deleni je vzdy realne cislo, nikdy integer}
Begin
 Writeln('Zadej dve cisla a,b. b by melo byt nenulove :');
 Readln(A,B);
 if b <> 0 then C:=A/B else Writeln('A ta nula, to je co?!, nulou delit neumim!');
 if b <> 0 then Writeln(A, ' / ', B, ' = ', C:5:4);
 Readln;
End.

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Program VypisProgramu;
Begin
 Writeln('Program Pythagoras;');
 Writeln('{Vypise vsechna reseni a2+b2=c2 na obrazovku (a,b,c <100);}');
 Writeln('Var A,B,C : Integer;');
 Writeln('Begin');
 Writeln(' For A:=1 to 100 do');
 Writeln('  For B:=1 to 100 do');
 Writeln('   For C:=1 to 100 do');
 Writeln('    if A*A +B*B = C*C then Write(a:3,'' '',b:3,'' '',c:4,''        '');');
 Writeln('      {Ta mezera je tam kvuli uprave, write aby se vsechno veslo na obrazovku}');
 Writeln(' Readln;');
 Writeln('End.');
Readln;
End.

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
