Which macro statement may cause an unexpected results ?
#define YEAR_LENGTH 365
#define MONTH_LENGTH 30
#define DAYCALC(y, m, d) ((y * YEAR_LENGTH) + (m * MONTH_LENGTH) + d)
int main()
{
int x = 5, y = 4 , z = 1;
cout << DAYCALC(x *3 , y %3 , z) << endl ;
cout << DAYCALC(x +12 , y , 300) << endl ;
cout << DAYCALC(x , 40 - y , 3+z) << endl ;
cout << DAYCALC(x , y , (z+50)) << endl ;
cout << DAYCALC(x , y %3 , z) << endl ;
cout << DAYCALC(4 % x , y++ , z) << endl;
return 0;
}
I run the program very well w/o any unexpected results.
Are there some hidden exceptions ?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…