int main(){
int N;
while(scanf(“%d”,&N)!=EOF){
int min,max;
scanf(“%d”,&min);
max=min;
for(int i=1;i<N;i++){
int temp;
scanf(“%d”,&temp);
min=(min<=temp)?min:temp;
max=(max>=temp)?max:temp;
}
if(min<10||max>30||max-min>3)printf(“Is not SBT\n”);
else printf(“Is SBT\n”);
}
}
找最大最小值就行了
include
int main(){
int N;
while(scanf(“%d”,&N)!=EOF){
int min,max;
scanf(“%d”,&min);
max=min;
for(int i=1;i<N;i++){
int temp;
scanf(“%d”,&temp);
min=(min<=temp)?min:temp;
max=(max>=temp)?max:temp;
}
if(min<10||max>30||max-min>3)printf(“Is not SBT\n”);
else printf(“Is SBT\n”);
}
}
确定是任意两座房子吗?
include
using namespace std;
int n,a,maxa,mina,i;
int main()
{
while(cin>>n){
cin>>a;
maxa=mina=a;
for(i=1;i>a;
if(a>maxa)maxa=a;
else if(a<mina)mina=a;
}
if(maxa<31&&mina>9&&maxa-mina<4)cout<<”Is SBT\n”;
else cout<<”Is not SBT\n”;
}
return 0;
}
死板做容易超时
include
include
int max, min;
int N;
void maxmin(int str[]){
int i;
for(i=0; i<N; i++){
if(maxstr[i]) {min = str[i];}
}
}
int st[110000];
int main() {
while (scanf(“%d”,&N) != EOF){
max=-10,min=40;
int i;
for(i=0; i30||min<10||max-min>3);
if(x==0){
printf(“Is SBT\n”);
}
else printf(“Is not SBT\n”);
}
return 0;
}