Janilabo

Janilabo | CompareVal() [SCAR Divi]

May 8th, 2013
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.61 KB | None | 0 0
  1. {==============================================================================]  
  2.   Explanation: Compares value v with x. Results: 0=EQUAL, 1=v>x, -1=v<x                  
  3. [==============================================================================}
  4. function CompareVal(v, x: Integer): Integer;
  5. begin
  6.   case (v <> x) of
  7.     True:
  8.     case (v > x) of
  9.       True: Result := 1;
  10.       False: Result := -1;
  11.     end;
  12.     False: Result := 0;    
  13.   end;
  14. end;
  15.  
  16. var
  17.   a, b: Integer;
  18.  
  19. begin
  20.   a := 100;
  21.   b := 50;
  22.   WriteLn(CompareVal(a, b));
  23.   WriteLn(CompareVal(1, 1));
  24.   WriteLn(CompareVal(b, a));
  25. end.
Advertisement
Add Comment
Please, Sign In to add comment