三、阅读程序写结果

1program j301;

var i,a,b,c,x,y:integer;

p:array[0..4] of integer;

begin

y:=20;

for i:=0 to 4 do read(p);

readln;

a:=(p[0]+p[1])+(p[2]+p[3]+p[4]) div 7;

b:=p[0]+p[1] div ((p[2]+p[3]) div p[4]);

c:=p[0]*p[1] div p[2];

x:=a+b-p[(p[3]+3) mod 4];

if (x>10)

then y:=y+(b*100-a) div (p[p[4] mod 3]*5)

else

y:=y+20+(b*100-c) div (p[p[4] mod 3]*5);

writeln(x,',',y);

end.

{注:本例中,给定的输入数据可以避免分母为0或数组元素下表越界。}

输入:6 6 5 5 3 输出:______________________

 

2program j302;

var a,b:integer;

var x,y:^integer;

procedure fun(a,b:integer);

var k:integer;

begin k:=a; a:=b; b:=k;

writeln(a,',',b);

 end;

begin

a:=3; b:=6;

x:=@a; y:=@b;

fun(x^,y^);

writeln(a,',',b);

end.

输出:_______________________________

 

3program j303;

var a1:array[1..50] of integer;

var i,j,t,t2,n,n2:integer;

begin

n:=50;

for i:=1 to n do a1[i]:=0;

n2:=round(sqrt(n));

for i:=2 to n2 do

if (a1[i]=0) then

begin

t2:=n div i;

for j:=2 to t2 do a1[i*j]:=1;

end;

t:=0;

for i:=2 to n do

if (a1[i]=0) then

begin

write(i:4); inc(t);

if (t mod 10=0) then writeln;

end;

writeln;

end.

输出:_____________________________________________

_____________________________________________

 

4Program j304;

Type str1=string[100];

Str2=string[200];

Var

S1:str1; s2:str2;

Function isalpha(c:char):Boolean;

Var i:integer;

Begin

i:=ord(c);

if ((i>=65) and (i<=90)) or ((i>=97) and (i<=122)) then

isalpha:=true

else isalpha:=false;

end;

function isdigit(c:char):Boolean;

var i:integer;

begin

i:=ord(c); if (i>=48) and (i<=57) then isdigit:=true

else isdigit:=false;

end;

procedure expand(s1:str1;var s2:str2);

var i,j:integer; a,b,c:char;

begin

j:=1; c:=char(1); i:=0;

while (i<=ord(s1[0])) do

begin inc(i); c:=s1[i];

if c='-' then begin

a:=s1[i-1]; b:=s1[i+1];

if (isalpha(a) and isalpha(b)) or (isdigit(a) and isdigit(b)) then begin

dec(j);

while (ord(upcase(a))<ord(upcase(s1[i+1]))) do

begin

s2[j]:=a; inc(j); inc(a); end;

end

else

begin s2[j]:=c; inc(j); end;

end

else begin s2[j]:=c; inc(j); end; end; s2[0]:=char(j-2); end;

begin readln(s1); expand(s1,s2); writeln(s2);

end.

输入:wer2345d-h454-82qqq 输出:__________________________

posted on 2008-11-14 15:13  sandboy  阅读(368)  评论(0)    收藏  举报