一、题目链接
http://noi.openjudge.cn/ch0104/01/
二、解题思路
◎ 给定的整数N存在三种可能性:
→ 大于0;
等于0;
小于0;
上述三种可能性是互斥的。
三、实施步骤
◎ 首先,定义并输入int类型的整数N,代表待判断的数;
◎ 其次:
→ 如果N>0:输出positive;
否则如果N==0:输出zero;
否则:输出negative。
四、C++程序
#include <iostream>
using namespace std;
int main()
{
int N;
cin >> N;
if (N > 0) // 如果N大于0
{
cout << "positive"; // 输出positive
}
else if (N == 0) // 否则如果N等于0
{
cout << "zero"; // 输出zero
}
else // 否则,N小于0
{
cout << "negative"; // 输出negative
}
return 0;
}