#include "iostream"
using namespace std;
void main()
{
cout<<"Please input a number: ";
int a;
cin>>a;
if (a>0&&a%2==0)
{
cout<<"输入的数是正偶数";
}
if (a<0&&a%2==0)
{
cout<<"输入的数是负偶数";
}
if (a<0&&a%2!=0)
{
cout<<"输入的数是负奇数";
}
if (a>0&&a%2!=0)
{
cout<<"输入的数是负奇数";
}
if (a==0)
{
cout<<"请输入一个非零整数,谢谢合作";
}
}
#include
int main()
{
int n;
printf("请输入一个整数: ");
scanf("%d",&n);
if(n>0)
{
if(n%2) printf("正奇数\n");
else printf("正偶数\n");
}
else if(n<0)
{
if(n%2) printf("负奇数\n");
else printf("负偶数\n");
}
else printf("0\n");
return 0;
}
框架省略
cin>>n;
if(n>0){
if(n%2)cout<<"zhengoushu"
else cout<<"zhengjishu"
}
else
{
if(n%2)cout<<"fuoushu"
else cout<<"fujishu"
}
cin>>n;
if(n%2)
{
if(n>0)
cout<<"ZhengOuShu"<
cout<<"FuOuShu"<
else
{
if(n>0)
cout<<"ZhengJiShu"<
cout<<"FuJiShu"<
如果恰好输入的是0,给什么结果阿?Undefined?呵呵