// // 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