错哪里了?一直十分?求大牛解释

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

栀久qwq @ 2017-04-28 12:22:57

var
 x,y,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10:longint;
begin
 read(y,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10);
 x:=0;
 if (y<a1) then 
  if (y+30>=a1) then x:=x+1
   else x:=x
    else x:=x+1;
if (y<a2) then 
  if (y+30>=a2) then x:=x+1
   else x:=x
    else x:=x+1;
if (y<a3) then 
  if (y+30>=a3) then x:=x+1
   else x:=x
    else x:=x+1;
if (y<a4) then 
  if (y+30>=a4) then x:=x+1
   else x:=x
    else x:=x+1;    
if (y<a5) then 
  if (y+30>=a5) then x:=x+1
   else x:=x
    else x:=x+1;    
if (y<a6) then 
  if (y+30>=a6) then x:=x+1
   else x:=x
    else x:=x+1;    
if (y<a7) then 
  if (y+30>=a7) then x:=x+1
   else x:=x
    else x:=x+1;    
if (y<a8) then 
  if (y+30>=a8) then x:=x+1
   else x:=x
    else x:=x+1;  
if (y<a9) then 
  if (y+30>=a9) then x:=x+1
   else x:=x
    else x:=x+1; 
if (y<a10) then 
  if (y+30>=a10) then x:=x+1
   else x:=x
    else x:=x+1;
write(x);
end.

by owogon @ 2017-04-28 16:44:55

做完之后先试一下样例,样例都过不了就别交了

输入格式看清楚不谢

var
 x,y,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10:longint;
begin
 read(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10);
 read(y);//y在第二行输入,这样就可以AC
 x:=0;
 if (y<a1) then 
  if (y+30>=a1) then x:=x+1
   else x:=x
    else x:=x+1;
if (y<a2) then 
  if (y+30>=a2) then x:=x+1
   else x:=x
    else x:=x+1;
if (y<a3) then 
  if (y+30>=a3) then x:=x+1
   else x:=x
    else x:=x+1;
if (y<a4) then 
  if (y+30>=a4) then x:=x+1
   else x:=x
    else x:=x+1;    
if (y<a5) then 
  if (y+30>=a5) then x:=x+1
   else x:=x
    else x:=x+1;    
if (y<a6) then 
  if (y+30>=a6) then x:=x+1
   else x:=x
    else x:=x+1;    
if (y<a7) then 
  if (y+30>=a7) then x:=x+1
   else x:=x
    else x:=x+1;    
if (y<a8) then 
  if (y+30>=a8) then x:=x+1
   else x:=x
    else x:=x+1;  
if (y<a9) then 
  if (y+30>=a9) then x:=x+1
   else x:=x
    else x:=x+1; 
if (y<a10) then 
  if (y+30>=a10) then x:=x+1
   else x:=x
    else x:=x+1;
write(x);
end.

不过其实这道题用循环和数组更方便

``pas var a:array[1..10] of longint; i,b,n:longint; begin b:=0;//计数器 for i:=1 to 10 do read(a[i]);//读入 read(n); for i:=1 to 10 do if a[i]<=n+30 then b:=b+1;//统计 writeln(b); end.


by owogon @ 2017-04-28 16:46:34

var 
  a:array[1..10] of longint;
  i,b,n:longint; 
begin 
  b:=0;//计数器 
  for i:=1 to 10 do read(a[i]);//读入 
  read(n);
   for i:=1 to 10 do if a[i]<=n+30  then b:=b+1;//统计 
  writeln(b);
end.

markdown完美的炸了


by 何炜华8864 @ 2017-04-28 16:50:00

'''

include<iostream>

'''


by 栀久qwq @ 2017-04-28 20:22:35

@姚起龙 是的啊,开始没有想到诶qwq,还是笨办法qwq


|