pascal答案

P1046 [NOIP2005 普及组] 陶陶摘苹果

陈俊熙abc123 @ 2017-05-24 16:39:14

var
        a:array[1..1000] of longint;
        i,j,n,m:longint;
begin
        for i:=1 to 10 do
                read(a[i]);
        read(n);
        for i:=1 to 10 do
                if n+30>=a[i] then inc(m);
        write(m);
end.

by Pascal周逸非 @ 2017-05-24 20:18:22

浪费内存,直接用10个存的数组就行了

const n=10;
var
     a:array[1..n] of longint;
     max,i,s:longint;
begin
     for i:=1 to n do  begin
         read(a[i]);
     end;
     readln(max);
     for i:=1 to n do  begin
         if a[i]<=(max+30) then s:=s+1;
     end;
     writeln(s);
end.

by 20041018xx @ 2017-06-02 21:52:31

const n=10;
var
     a:array[1..n] of longint;
     max,i,s:longint;
begin
     for i:=1 to n do  begin
         read(a[i]);
     end;
     readln(max);
     for i:=1 to n do  begin
         if a[i]<=(max+30) then s:=s+1;
     end;
     writeln(s);
end.

by 飞天者 @ 2017-06-03 20:24:00

@kkksc03

有人发答案!!!


|