爱编程 @ 2017-05-09 12:57:37
type arr=array[1..10] of longint;
var a:arr;
i,n,z,c:longint;
Begin
z:=0; c:=30;
for i:=1 to 10 do
readln(a[i]);
read(n);
for i:=1 to 10 do
Begin
if n>a[i] then z:=z+1
else if n+30>a[i] then z:=z+1
else z:=z+0;
end;
write(z);
end.
by o泡沫半夏o @ 2017-05-10 12:58:54
var
a:array[1..10]of longint; //不懂你原来代码意思所以干脆重写一个了;
i,n,z:longint;
Begin
z:=0;
for i:=1 to 10 do
read(a[i]);
read(n);
for i:=1 to 10 do
begin
if (n+30)>=a[i] then z:=z+1 //这里可以直接用陶陶的身高+凳子的高度去比较,建议你不用
else z:=z; 设一个量表示凳子的高度,且比较时是包括等于的;
end;
write(z);
end.
by Kingkong @ 2017-05-20 14:27:00
我补充一下,楼上的if (n+30)>=a[i] then z:=z+1 else z:=z; 这句else z:=z可以去掉
by xzjds @ 2017-05-22 12:50:37
我把你的代码改一下就对了,首先不能用readln,其次在for的时候应该加begin和and
by xzjds @ 2017-05-22 12:51:59
type arr=array[1..10] of longint;
var a:arr;
i,n,z,c:longint;
Begin
z:=0; c:=30;
for i:=1 to 10 do
begin
read(a[i]);
end;
read(n);
for i:=1 to 10 do
Begin
if n>a[i] then z:=z+1
else if n+30>a[i] then z:=z+1
else z:=z+0;
end;
write(z);
end.