C++宏的计算规则

#include "iostream"
using namespace std;

#define N 2+3
#define M (2+3)
#define area1(L) L*L
#define area2(L) (L)*(L)
#define area3(L) ((L)*(L))
void main()
{
	int a = N * N;	//2+3*2+3=11
	int b = M * M;	//(2+3)*(2+3)=25
	cout << a << endl;
	cout << b << endl;
	int S1 = area1(2 + 4);	//2+2*4+4=14
	int S2 = area2(2 + 4);	//(2+4)*(2+4)=36
	float Q1 = area1(2 + 4) / area1(2 + 4);	//2+2*4+4/2+2*4+4=24
	float Q2 = area2(2 + 4) / area2(2 + 4);	//(2+4)*(2+4)/(2+4)*(2+4)=36      =       int S2 = area2(2 + 4)
	float Q3 = area3(2 + 4) / area3(2 + 4);	//(2+2*4+4)/(2+2*4+4)=1
	cout << S1 << endl;
	cout << S2 << endl;
	cout << Q1 << endl;
	cout << Q2 << endl;
	cout << Q3;
}

你可能感兴趣的:(C++)