黎明时空几何 @ 2017-01-28 21:52:28
var
a:array[1..10] of longint;
i,j,ans:longint;
begin
for i:=1 to 10 do read(a[i]);
readln(j);
j:=j+30;
ans:=0;
for i:=1 to 10 do
if a[i]<=j then inc(ans);
writeln(ans);
end.
@ 黎明时空几何 2017-01-28 21:51 回复
#include <stdio.h>
int a[10000];
int main()
{
int i;
int sum;
for (i=0;i<=9;i++) scanf("%d",&a[i]);
int s;
scanf("%d",&s);
s=s+30;
for (i=0;i<=10;i++) if (a[i]<=s) sum=sum+1;
printf("%d",sum);
return 0;
}
什么错误? 我下了个数据输出是对的,但评测错了。
by asuldb @ 2017-01-29 07:39:42
楼主你第二次循环做了11次啊
by asuldb @ 2017-01-29 07:42:02
for(i=0;i<10;i++)就行
by bcku1 @ 2017-01-29 14:00:17
for(i=0;i<9;i++)就行
by gengzx @ 2017-03-13 14:04:06
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
int a[10],b,i,apple=0;
for(i=1;i<=10;i++)
cin>>a[i];
cin>>b;
for(i=1;i<=10;i++)
{
if(a[i]<=b+30)
apple=apple+1;
}
cout<<apple;
return 0;
}