题目
第一节 if选择结构
1039:判断数正负
题目链接
#include<iostream>
using namespace std;
int main(){
int n;
cin>>n;
if(n>0)cout<<"positive"<<endl;
else if(n==0)cout<<"zero"<<endl;
else cout<<"negative"<<endl;
return 0;
}
1040:输出绝对值
题目链接
#include<cstdio>
using namespace std;
int main(){
double a;
scanf("%lf",&a);
if(a<0)a*=-1.0;
printf("%.2lf",a);
return 0;
}
1041:奇偶数判断
题目链接
#include<iostream>
using namespace std;
int main(){
int n;
cin>>n;
if(n%2==0)cout<<"even\n";
else cout<<"odd\n";
return 0;
}
1042:奇偶ASCII值判断
题目链接
#include<iostream>
using namespace std;
int main(){
char a;
int b;
cin>>a;
b=a;
if(b%2==0)cout<<"NO"<<endl;
else cout<<"YES"<<endl;
return 0;
}
1043:整数大小比较
题目链接
#include<iostream>
using namespace std;
int main(){
int x,y;
cin>>x>>y;
if(x>y)cout<<'>'<<endl;
else if(x==y)cout<<'='<<endl;
else cout<<'<'<<endl;
return 0;
}
1044:判断是否为两位数
题目链接
#include<iostream>
using namespace std;
int