wsqgh @ 2022-12-16 13:55:48
#include<iostream>
using namespace std;
const int N = 100010;
int a[N];
int main()
{
int H,n=0,i;
for(i=1;i<=10;i++)
scanf("%d",& a[i]);
scanf("%d",&H);
while(i--)
{
if(H+30>=a[i])
n++;
}
printf("%d",n);
return 0;
}
``
by hanjinshou @ 2023-01-28 17:53:25
@tangrunxi 哦明白了
by small_Dongpo @ 2023-02-05 15:48:05
我这种代码可能更简单一些,代码如下:
#include <iostream>
using namespace std;
const int NUM = 10;
int a[15];
int main()
{
for (int i = 1; i <= NUM; ++i)
{
cin >> a[i];
}
int n, cnt = 0;
cin >> n;
n += 30;
for (int i = 1; i <= NUM; ++i)
{
if (n >= a[i]) cnt++;
}
cout << cnt;
}