一个PASCAL程序

Like
Like Love Haha Wow Sad Angry
1

自己编的

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
Like
Like Love Haha Wow Sad Angry
1

发表评论

电子邮件地址不会被公开。 必填项已用*标注