1)var
a:array [1..5] of char;
s:string;
flag:boolean;
i:integer;
begin
flag:=false;
a[1]:='D'; a[2]:='H'; a[3]:='Y';
a[4]:='S'; a[5]:='T';
readln(s);
for i:=1 to 5 do
if a[i]=s[length(s)] then
flag:=true;
break;
end;
if flag then writeln('True')
else writeln('False');
end.
2)var
for i:=1 to length(s) do
if s[i] = 'G' then
writeln('G');
end
else if s[i] = 'J' then
writeln('J');
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
1)var
a:array [1..5] of char;
s:string;
flag:boolean;
i:integer;
begin
flag:=false;
a[1]:='D'; a[2]:='H'; a[3]:='Y';
a[4]:='S'; a[5]:='T';
readln(s);
for i:=1 to 5 do
if a[i]=s[length(s)] then
begin
flag:=true;
break;
end;
if flag then writeln('True')
else writeln('False');
end.
2)var
s:string;
i:integer;
begin
readln(s);
for i:=1 to length(s) do
if s[i] = 'G' then
begin
writeln('G');
break;
end
else if s[i] = 'J' then
begin
writeln('J');
break;
end;
end.