Janilabo

Janilabo | Compare() [Simba]

Jun 20th, 2012
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.58 KB | None | 0 0
  1. function Compare(s1, s2: string): Integer;
  2. begin
  3.   if s1 <> s2 then
  4.     if s1 > s2 then
  5.       Result := 1
  6.     else
  7.       Result := -1;
  8. end;
  9.  
  10. function GetRelation(s1, s2: string): string;
  11. var
  12.   r: Integer;
  13. begin
  14.   r := Compare(s1, s2);
  15.   case r of
  16.     -1: Result := ('"' + s1 + '" < "' + s2 + '"');
  17.     0: Result := ('"' + s1 + '" = "' + s2 + '"');
  18.     1: Result := ('"' + s1 + '" > "' + s2 + '"');
  19.   end;
  20. end;
  21.  
  22. begin
  23.   ClearDebug;
  24.   WriteLn(GetRelation('ABCD A', 'ABCD B'));
  25.   WriteLn(GetRelation('ABCD B', 'ABCD B'));
  26.   WriteLn(GetRelation('ABCD C', 'ABCD B'));
  27. end.
Advertisement
Add Comment
Please, Sign In to add comment