#include <iostream>
using namespace std;
#define POSITIVE(x) ((x) > 0) //x为正数,输出为1;x为负数,输出为0
#define NEGATIVE(x) ((x) < 0) //x为正数,输出为0;x为负数,输出为1
#define VAR(x) (((x) > 0) ? (x) : (-(x))) //输出x的绝对值
int main()
{
int a = 9;
int b = -5;
cout << POSITIVE(a) << endl;
cout << NEGATIVE(a) << endl;
cout << VAR(a) << endl;
cout << POSITIVE(b) << endl;
cout << NEGATIVE(b) << endl;
cout << VAR(b) << endl;
system("pause");
return 0;
}
#define VAR(x) (((x) > 0) ? (x) : (-(x)))——c++
最新推荐文章于 2022-11-04 14:49:08 发布