为什么只有10分?

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

yuhengtong222 @ 2016-08-17 10:14:49

var
  n,i,x,k:longint;
  a:array[1..1000000] of longint;
begin
  for i:=1 to 10 do read(a[i]);
  readln(n);
  k:=30;
  x:=0;
  for i:=1 to 10 do;
  if n+k>=a[i] then x:=x+1;
  write(x);
end.

by GZOIxhx @ 2016-08-17 10:36:53

for i:=1 to 10 do 后面打了分号?


by GZOIxhx @ 2016-08-17 10:38:56

这样就只判断了第十个苹果能否摘到


by 20030103pz @ 2016-08-17 12:36:16


by syszs @ 2016-09-15 13:43:29

你这样做不对


by huzhaoyang @ 2016-09-16 08:42:45

嗯嗯嗯

把那个分号去掉


by Wh_Xcjm @ 2016-09-29 20:46:49

#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<cmath>
using namespace std;
int main()
{
    int i,j,s=0,a[11];
    for(i=1;i<=10;i++)
        cin>>a[i];
    cin>>i;
    for(j=1;j<=10;j++)
        if(a[j]<=i+30)
            s++;
    cout<<s;
    return 0;
}

|