几道pascal题目!急急急!!今天就要,能有多少是多少

2024-12-18 00:12:54
推荐回答(1个)
回答1:

1.
Var i,j,k,n,len,num,p,temp:longint;
a:array[1..200] of integer;
b:array[1..200] of qword;
s:string;

function pow(a,times:integer):longint;
var i:integer;
temp:longint;
begin
temp:=a;
for i:=2 to times do
begin
temp:=temp*a;
end;

exit(temp);
end;

begin
assign(input,'ghillie.in');reset(input);
assign(output,'ghillie.out');rewrite(output);

readln(n);

len:=0;
while not eoln do
begin
inc(len);
read(a[len]);
end;

for i:=1 to n do
begin
fillchar(b,sizeof(b),0);

for j:=1 to len do
begin
str(a[j],s);

for k:=1 to length(s) do
begin
val(s[k],num,p);
b[j]:=b[j]+pow(num,i+1);
end;
end;

for j:=1 to len do
begin
for k:=1 to len do
if a[j]=b[k] then
begin
a[j]:=-1;
break;
end;
end;

end;

for i:=1 to len-1 do
for j:=i+1 to len do
if a[i]>a[j] then
begin
temp:=a[i];
a[i]:=a[j];
a[j]:=temp;
end;

for i:=1 to len do if a[i]<>-1 then write(a[i],' ');

close(input);close(output);
end.

//还没有处理打印最后一位后空格,但样例有空格