ex1.pas 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. Program Main;
  2. const tt=101;ff=102;err=103;
  3. var state:record w,v,x,y,z:integer end;
  4. function PLUS (a,b:integer) :integer;
  5. begin if (a>100) or (b>100) then Plus:=err
  6. else if a+b >100 then Plus:=err
  7. else Plus:=a+b; end;
  8. function LESS (a,b:integer) :integer;
  9. begin if (a>100) or (b>100) then Less:=err
  10. else if a<b then Less:=tt
  11. else Less:=ff; end;
  12. Procedure Val(a:integer);
  13. begin case a of
  14. 101 : writeln ('tt');
  15. 102 : writeln ('ff');
  16. 103 : writeln ('err');
  17. otherwise writeln (a);end;end;
  18. BEGIN WITH STATE DO BEGIN
  19. w:=1;v:=1;x:=1;y:=1;z:=1;
  20. Z := 1 ;
  21. X := PLUS( Z , 1 ) ;
  22. Y := 1 ;
  23. WHILE LESS( Y , PLUS( X , 1 ) ) =tt DO BEGIN
  24. Z := PLUS( Z , Z ) ;
  25. Y := PLUS( Y , 1 ) ;
  26. END;
  27. IF LESS( Y , PLUS( X , 1 ) ) =err THEN x:=err;
  28. V := PLUS( 1 , 1 ) ;
  29. V := PLUS( PLUS( V , V ) , V ) ;
  30. W := 1 ;
  31. Writeln (' Post-DUMP : ');
  32. Write ('w=');Val(w);
  33. Write ('v=');Val(v);
  34. Write ('x=');Val(x);
  35. Write ('y=');Val(y);
  36. Write ('z=');Val(z);
  37. readln;end;
  38. END.