(中文) 一个PASCAL程序

Like
Like Love Haha Wow Sad Angry
5

Sorry, this entry is only available in 中文. 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
Like
Like Love Haha Wow Sad Angry
5

Leave a Reply

Your email address will not be published. Required fields are marked *

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax