关于Pascal语言的习题

2024-10-31 11:36:46
推荐回答(4个)
回答(1):

var
a:char;
begin
readln(a);
case a of
'A','a':writeln(1);
'B','b':writeln(2);
'C','c':writeln(3);
'D','d':writeln(4);
else writeln(5);
end;
end.

回答(2):

Program exp;

var ch:char;

begin
readln(ch);
if ('A'<=ch) and (ch<='D') then
writeln(ord(ch)-64)
else
if ('a'<=ch) and (ch<='d') then
writeln(ord(ch)-96)
else
writeln(5);
end.

回答(3):


var a,q,w:longint;
c:boolean;
begin
for a:=1000 to 9999 do begin
c:=true;
for q:=1 to 10 do if a mod q<>q-1 then c:=false;
if c then write(a:8);
end;
writeln;
end.

答案:2519 5039 7559

回答(4):

var
i,j:set of char;
k:char;
begin
readln(k);
i:=['A','B','C','D'];
j:=['a','b','c','d'];
if k in i then writeln(ord(k)-64)
else if k in j then writeln(ord(k)-96)
else writeln(5);
end.