Kulverstukas

Check if we can make a triangle

Aug 7th, 2010
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.37 KB | None | 0 0
  1. program trikampis_bendrai;
  2.   uses crt;
  3.   var a, b, c : integer;
  4.       r : char;
  5.   label start;
  6. begin
  7. start:ClrScr;
  8.  a := 0;
  9.  b := 0;
  10.  c := 0;
  11. repeat                   //kartojam kol yra nuliniu reiksmiu
  12.      ClrScr;
  13.     TextColor (white);
  14.    GotoXY (2,2);
  15.   Write ('Ivesk trikampio krastines, atskirtas tarpais: ');
  16.     Read (a, b, c);
  17.      if (a > 0) and (b > 0) and (c > 0) then      //tikrinam ar yra nuliniu reiksmiu
  18.       begin
  19.        GotoXY (2,3);
  20.         Write ('Neteisingos reiksmes!');
  21.        Delay (2000);
  22.        end;
  23. {      Repeat
  24.      ClrScr;
  25.    GotoXY (2,2);
  26.   Write ('Ivesk trikampio krastines, atskirtas tarpais: ');
  27.     Read (a, b, c); }
  28.      until (a >= 1) or (b >= 1) or (c >= 1);    //kai nebera nuliniu reiksmiu pradedam likusia daly
  29.       //end
  30.      //else
  31.       //begin
  32.        if (a + b > c ) and (a + c > b) and (b + c > a) then   //jaigu dvieju atkarpu suma didesne uz treciaja tai
  33.           begin
  34.            GotoXY (3,4);
  35.              TextColor (green);
  36.             Write ('Trikampty sudaryti galima!');
  37.           end
  38.        else
  39.           begin
  40.            GotoXY (3,4);
  41.              TextColor (red);
  42.             Write ('Trikampy sudaryti negalima!');
  43.           end;
  44.   GotoXY (2,5);
  45.    Write ('Kartoti?: ');
  46.     Read (r);
  47.      r := readkey;
  48.      Case r of
  49.         't' : Goto Start;
  50.         'n' : halt;
  51.      end;
  52.    //end;
  53. end.
Add Comment
Please, Sign In to add comment