信息学奥赛一本通习题答案
最近在给小学生做C++的入门培训,用的教程是信息学奥赛一本通,刷题网址为http://ybt.ssoier.cn:8088/index.php
现将部分习题的答案放在博客上,希望能给其他有需要的人带来帮助
篇幅有限,所以从分支结构开始,所有代码都可以正确提交,鉴于本人能力有限以及教学需要,部分代码写的不是那么简洁,望诸位多多指教。
以下是题号和代码
2051
#include<iostream>
using namespace std;
int main(){
int a;
cin>>a;
if(a%2 == 0) cout<<"yes";
}
2052
#include<iostream>
using namespace std;
int main(){
int a;
cin>>a;
if(a > 1&&a<100) cout<<"yes";
}
2053
#include<iostream>
using namespace std;
int main(){
int a,b,c;
cin>>a>>b>>c;
if(a < b){
int t = a;
a = b;
b = t;
}
if(a < c){
int t = a;
a = c;
c = t;
}
if(b < c){
int t = b;
b = c;
c = t;
}
cout<<a<<" "<<b<<" "<<c;
}
2054
#include<iostream>
using namespace std;
int main(){
int a;
cin>>a;
if(a >= 25&&a<=30) cout<<"ok!";
else cout<<"no!";
}
2055
#include<iostream>
#include<iomanip>
using namespace std;
int main(){
double n,q;
cin>>n;
if(n<=20) q = 1.68*n;
else if(n>20)
q = 1.98*n;
cout<<fixed<<setprecision(2)<<q;
}
2056
#include<iostream>
using namespace std;
int main(){
double a,b,c;
cin>>a>>b>>c;
if(a<b){
double t =a;
a = b;
b = t;
}
if(a<c){
double t =a;
a = c;
c = t;
}
cout<<a;
}
1039
#include<iostream>
using namespace std;
int main(){
long int a;
cin>>a;
if(a>0) cout<<"positive";
else if(a == 0) cout<<"zero";
else if(a<0) cout<<"negative";
}
1040
#include<iostream>
#include<iomanip>
using namespace std;
int main(){
double n,q;
cin>>n;
if(n>=0) q = n;
else if(n<0)
q = -1*n;
cout<<fixed<<setprecision(2)<<q;
}
1041
#include<iostream>
#include<iomanip>
using namespace std;
int main(){
int a;
cin>>a;
if(a%2 == 0) cout<<"even";
else cout<<"odd"
}
1042
#include<iostream>
#include<iomanip>
using namespace std;
int main(){
char a;
cin>>a;
int q =a+0;
if(q%2 == 0) cout<<"NO";
else cout<<"YES";
}
1043
#include<iostream>
#include<iomanip>
using namespace std;
int main(){
int a,b;
cin>>a>>b;
if(a > b) cout<<">";
else if(a == b) cout<<"=";
else cout<<"<";
}
1044文章来源:https://uudwc.com/A/noVBb
#include<iostream>
#include<iomanip>
using namespace std;
int main(){
int a;
cin>>a;
if(a<100&&a>10) cout<<1;
else cout<<0;
}
1045文章来源地址https://uudwc.com/A/noVBb
#include<iostream>
#include<iomanip>
using namespace std;
int main(){
int a,b;
cin>>a>>b;
if(a>=10||b>=20) cout<<1;
else cout<<0;
}