Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {==============================================================================]
- Explanation: Compares s1 with s2.
- Results: 0=EQUAL, 1=s1>s2, -1=s1<s2
- [==============================================================================}
- function Compare(s1, s2: string): Integer;
- begin
- case (s1 <> s2) of
- True:
- case (s1 > s2) of
- True: Result := 1;
- False: Result := -1;
- end;
- False: Result := 0;
- end;
- end;
- function GetRelation(s1, s2: string): string;
- var
- r: Integer;
- begin
- r := Compare(s1, s2);
- case r of
- -1: Result := ('"' + s1 + '" < "' + s2 + '"');
- 0: Result := ('"' + s1 + '" = "' + s2 + '"');
- 1: Result := ('"' + s1 + '" > "' + s2 + '"');
- end;
- end;
- begin
- ClearDebug;
- WriteLn(GetRelation('ABCD A', 'ABCD B'));
- WriteLn(GetRelation('ABCD B', 'ABCD B'));
- WriteLn(GetRelation('ABCD C', 'ABCD B'));
- end.
Advertisement
Add Comment
Please, Sign In to add comment