请高手们解决几道PASCAL初级问题

来源:百度知道 编辑:UC知道 时间:2024/06/05 09:05:07
1:输入x,y,输出其最大公约数
2:输入一个二进制数,输出十进制
3:求1到100间所有偶数的和(包括100)
4:输入15个数,统计其中正,负,零的个数循环

1.
var a,b,c,d,e:integer;
begin
readln(a,b);
if a<>b then
begin
if a<b then begin d:=a;a:=b;b:=d;end;
c:=a mod b;
while c<>0 do
begin
a:=b;b:=c;
c:=a mod b;
end;
e:=b;
writeln('e=',e);
end else writeln('e=',1);
end.

2.
var total,l,i,temp:integer;st:string;
begin
readln(st);
total:=0;l:=length(st);
for i:=l downto 1 do
if st[i]='1' then begin
temp:=1;
for j:=1 to l-i do temp:=temp*2;
inc(total,temp);
end;
writeln(total);
end.

3.
var total,i:integer;
begin
total:=0;
for i:=1 to 50 do inc(total,i);
writeln(total*2);
end.

4.var zs,fs,lin,i:byte;c:integer;
zs:=0;fs:=0;lin:=0;
for i:=1 to 15 do begin
read(c);
if c>0 then inc(zs) else
if c<0 then inc(fs) else
inc(lin);
e