求大神,C++,为什么只有20分?

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

Dillct @ 2017-02-02 16:46:51

本人是新手

#include<cstdio>
using namespace std;
int main()
{
    int t,a[10],ans=0;
    for(int i=0;i<10;i++) scanf("%d",&a[i]);
    scanf("%d",&t);
    t+=30;
    for(int i=0;i<10;i++)
    {
        if(a[i]>t)
        ans++;
    }
    printf("%d",ans);
    return 0;
}

by 天道酬勤 @ 2017-02-02 17:28:46

pascal表示看不懂

var
 a:array[1..11] of integer;
 ans,i,l:integer;
begin
 for i:=1 to 10 do read(a[i]);
 readln(l);
 l:=l+30;
 ans:=0;
 for i:=1 to 10 do 
  begin
   if a[i]<=l then ans:=ans+1;
  end;
 writeln(ans);
end.
这是我的程序,希望对你能有帮助

by Shan_Xian @ 2017-02-02 18:30:02

是t>=a[i]


by xyx_xcc @ 2017-02-25 09:54:45

pascal是傻逼,c++看都看不懂,有你妈个帮助


by SWQC @ 2017-03-04 09:25:37

#include<iostream>
using namespace std;
int a[10];
int main()
{
    int l,i,t;
    int n=0;
    for(i=0;i<10;++i)
    cin>>a[i];
    cin>>l;
    t=l+30;
    for(i=0;i<10;++i)
    {
    if(a[i]<=t)
    n++;
    }
    cout<<n;
    return 0;
}

by 陈三成 @ 2017-03-04 17:22:53

请问,用C语言怎么解?


by 秘晨阳 @ 2017-03-17 23:49:42

# include <iostream>
using namespace std;
int main ()
{int a[10],t,zt,apple=0;
for(int i=1;i<=10;i++)
   cin>>a[i];
cin>>t;
zt=t+30;
for(int i=1;i<=10;i++)
   if(zt>=a[i]) 
   apple++;
cout<<apple;   
}

|