SCAR Code:
program New;
function InRange(Value, Min, Max: Integer): Boolean;
begin
Result := (Value >= Min) and (Value <= Max);
end;
function UpperCase(c: string): string;
var
i, t: Integer;
begin
Result := c;
for i := 1 to Length(c) do
begin
t := Ord(c[i]);
if InRange(t, 97, 122) then
Result[i] := Chr(t - 32);
end;
end;
function LowerCase(c: string): string;
var
i, t: Integer;
begin
Result := c;
for i := 1 to Length(c) do
begin
t := Ord(c[i]);
if InRange(t, 65, 90) then
Result[i] := Chr(t + 32);
end;
end;
function GetLetters(s: string): string;
var
i: Integer;
begin
Result := '';
for i := 1 to Length(s) do
case s[i] of
'a'..'z', 'A'..'Z': Result := Result + s[i];
end;
end;
function GetNumbers(s: string): string;
var
i: Integer;
begin
Result := '';
for i := 1 to Length(s) do
case s[i] of
'0'..'9': Result := Result + s[i];
end;
end;
function GetOthers(s: string): string;
var
i: Integer;
begin
Result := '';
for i := 1 to Length(s) do
begin
case s[i] of
'0'..'9', 'a'..'z', 'A'..'Z': Continue;
end;
Result := Result + s[i];
end;
end;
function TrimLetters(s: string): string;
var
i: Integer;
begin
Result := '';
for i := 1 to Length(s) do
begin
case s[i] of
'a'..'z', 'A'..'Z': Continue;
end;
Result := Result + s[i];
end;
end;
function TrimNumbers(s: string): string;
var
i: Integer;
begin
Result := '';
for i := 1 to Length(s) do
begin
case s[i] of
'0'..'9': Continue;
end;
Result := Result + s[i];
end;
end;
function TrimOthers(s: string): string;
var
i: Integer;
begin
Result := '';
for i := 1 to Length(s) do
case s[i] of
'0'..'9', 'a'..'z', 'A'..'Z': Result := Result + s[i];
end;
end;
begin
WriteLn(BoolToStr(InRange(10, 5, 15)));
WriteLn(LowerCase('HaI!@#'));
WriteLn(UpperCase('HaI!@#'));
WriteLn(GetLetters('ohai123!@#'));
WriteLn(GetNumbers('ohai123!@#'));
WriteLn(GetOthers('ohai123!@#'));
WriteLn(TrimLetters('ohai123!@#'));
WriteLn(TrimNumbers('ohai123!@#'));
WriteLn(TrimOthers('ohai123!@#'));
end.