(中文) 一个PASCAL程序

Извините, этот техт доступен только в “中文”. For the sake of viewer convenience, the content is shown below in the alternative language. You may click the link to switch the active language.

自己编的

program sequence(input,output);
{$r-,s-,q-}
var
       a:array[1..10] of 0..1;
       input,output:text;
       x,y,n,w:longint;
       i:longint;
       s:longint;
function xny(a,b,c:longint):longint;
       var
           tv:integer;
       begin
           c:=1;
           for tv:=1 to b do
               c:=c*a;
       xny:=c;
       end;
begin
       for i:=1 to 10 do
           a[i]:=0;
       s:=0;
       assign(input,'sequence.in');
       reset(input);
       readln(input,n,w);
       close(input);
       i:=10;
       while w>0 do
           begin
               a[i]:=w mod 2;
               w:=w div 2;
               i:=i-1;
           end;
               for i:=1 to 10 do writeln(a[i]);
       for i:=10 downto 1 do
               begin
                   if a[i]=1 then s:=s+xny(n,10-i,y);
               end;
        assign(output,'sequence.out');
        rewrite(output);
        writeln(output,s);
        close(output);
end.

哪位大虾优化一下input: [‘input] n. 输入

2006-12-20
freetiger18 :