wangzaixi @ 2024-09-16 09:50:47
#include<iostream>
using namespace std;
int main(){
long long a[12],x,sum=0;
for(int i=0;i<10;i++){
cin>>a[i];
}
cin>>x;
x+=30;
for(int i=0;i<10;i++){
if(a[i]<x){
sum++;
}
}
cout<<sum;
return 0;
}
我加
by kanqiqin @ 2024-09-16 09:53:28
if(a[i]<x)
改成
if(x>=a[i])
by xuziheng0905 @ 2024-09-16 09:54:50
对,题目说是碰到,不是超过
by Max_menghx @ 2024-09-16 09:56:43
第11行应改为a[i]<=x才对
by wangzaixi @ 2024-09-16 09:56:44
@kanqiqin 过了
#include<iostream>
using namespace std;
int main(){
long long a[12]={0},x,sum=0;
for(int i=0;i<10;i++){
cin>>a[i];
}
cin>>x;
x+=30;
for(int i=0;i<10;i++){
if(a[i]<=x){
sum++;
}
}
cout<<sum;
return 0;
}
by jiangdangdang @ 2024-09-27 20:47:18
#include <bits/stdc++.h>
using namespace std;
int a[1010],b,ans;
int main()
{
for(int i=1;i<=10;i++)
{
cin>>a[i];
}
cin>>b;
for(int i=1;i<=10;i++)
{
if(b+30>=a[i]) ans++;
}
cout<<ans;
return 0;
}