名字重要吗 @ 2020-03-13 17:51:37
#include<bits/stdc++.h>
using namespace std;
int main() {
int a[10],tt,sum;
for(int i=0; i<10; i++)
cin>>a[i];
cin>>tt;
for(int i=0; i<10; i++)
if(tt>a[i]||tt+30>a[i])
sum++;
cout<<sum;
return 0;
}
by liqingyang @ 2020-03-13 17:52:16
@信号山 等于也算
by pkyT_T @ 2020-03-13 17:52:21
头像不和谐
by Scrutiny @ 2020-03-13 17:52:56
头像好评
by pkyT_T @ 2020-03-13 17:53:35
应该是>=
by LinkCutTree @ 2020-03-13 17:53:40
头像好评
by liqingyang @ 2020-03-13 17:54:10
if(tt>a[i]||tt+30>a[i])
改为:
if(tt>=a[i]||tt+30>=a[i])
优化:
if(tt+30>=a[i])
by pkyT_T @ 2020-03-13 17:54:41
if(tt>a[i]||tt+30>=a[i])
sum++;
by Aw顿顿 @ 2020-03-13 17:55:48
按我的码风改了一下
#include<bits/stdc++.h>
using namespace std;
int a[11],t,sm;
int main(){
for(int i=0;i<10;++i)cin>>a[i];
cin>>t;
for(int i=0;i<10;i++)if(t+30>=a[i])sm++;
cout<<sm<<endl;
return 0;
}
by Aw顿顿 @ 2020-03-13 17:57:15
@信号山
if(tt>a[i]||tt+30>a[i])
当中对于
若
同时,只要能够摘到,只需判断尽可能高的情况:
改为:
if(tt+30>a[i])
这样就简便多了。
by Aw顿顿 @ 2020-03-13 17:57:35
当然是要>=
才对