// // Fraction.h // OC12预处理程序 // // Created by Zoujie on 15/9/17. // Copyright (c) 2015年 Zoujie. All rights reserved. // //一般预定义常量的替换 #define kTURE 1 #define kFALSE 0 #define PI 3.141592 #define MAXIMUM_DATA_VALUES 1000 //更高级的预定义 #define TWO_PI 2.0 * 3.141592654 #define AND && #define OR || #define EQUALS == #define TWO_PI_Define 2.0 * PI //带参数 #define IS_LEAP_YEAR(y) y%4 == 0 && y%100 !=0 || y%400==0 #define SQUARE(x) x * x //运算错误 x代表表达式: x = y + 1 #define SQUARE_TURE(x) ((x)*(x)) #define MakeFract(x,y) ([[Fraction alloc]initWith: x over :y]) //? #define MAX_TWO_NUMBER(a,b) (((a)>(b)) ? (a):(b)) //判断两参数大小 #define IPAD //申明 #import <Foundation/Foundation.h>//<>系统头文件 @interface Fraction : NSObject -(void)defineProduct; -(double) area; -(double) circumference; -(void)initWith:x over:y; @end
// // Fraction.m // OC12预处理程序 // // Created by Zoujie on 15/9/17. // Copyright (c) 2015年 Zoujie. All rights reserved. // #import "Fraction.h" @implementation Fraction { int radius ;//半径 } -(void)defineProduct { int gameover = kFALSE; if (gameover == kFALSE) { gameover = kTURE; } if (gameover >0 AND (gameover <= 1)){} if (gameover >0 OR (gameover <= 1)){} } -(double) area { radius = 10; return PI * radius * radius; } -(double) circumference { return 2.0 * PI * radius; return TWO_PI * radius; return TWO_PI_Define * radius; } -(void)initWith:(id)x over:(id)y { return ; } @end
// // main.m // OC12预处理程序 // // Created by Zoujie on 15/9/17. // Copyright (c) 2015年 Zoujie. All rights reserved. // #import <Foundation/Foundation.h> #import "Fraction.h" #import <limits.h> #import <float.h> int main(int argc, const char * argv[]) { @autoreleasepool { if (IS_LEAP_YEAR(2000)) { NSLog(@"判断闰年"); } NSLog(@"%d",MAX_TWO_NUMBER(100, 99)); } return 0; } #pragma mark 条件编译 #ifdef IPAD //IPAD 申明就可以 #define kImageFile @"bardHD.png" #else # define kImageFile @"barn.png" #endif //用于注释 #if 0 #endif #undef 语句 //使一些已经地宫一的名称成为未定义的 #undef IPAD //消除IPAD #ifdef IPAD #if defined(IPAD) 判断都为FALSE
时间: 2024-11-08 13:34:54