【iOS7开发快速入门】代码示例3-5

来源:互联网 发布:淘宝开通网商银行账户 编辑:程序博客网 时间:2024/05/16 15:09
以下程序通过使用自增自减运算符实现运算。程序代码如下:

#import <Foundation/Foundation.h>int main(int argc, const char * argv[]) {    @autoreleasepool {        // insert code here...        NSLog(@"Hello, This is a sample 3.5 of the book 《iOS7 开发快速入门》!");        int a;        a=9;        NSLog(@"%i,%i",a,++a);        NSLog(@"%i,%i",a,a++);        NSLog(@"%i,%i",a,--a);        NSLog(@"%i,%i",a,a--);        NSLog(@"%i",a);    }    return 0;}

运行结果如下:
2015-01-18 11:16:50.181 Sample.3.5[1045:67812] Hello, This is a sample 3.5 of the book 《iOS7 开发快速入门》!
2015-01-18 11:16:50.182 Sample.3.5[1045:67812] 9,10
2015-01-18 11:16:50.182 Sample.3.5[1045:67812] 10,10
2015-01-18 11:16:50.182 Sample.3.5[1045:67812] 11,10
2015-01-18 11:16:50.183 Sample.3.5[1045:67812] 10,10
2015-01-18 11:16:50.183 Sample.3.5[1045:67812] 9
Program ended with exit code: 0
0 0
原创粉丝点击