决定今天开始学OC,之前有一些C语言基础。
编程环境:
操作系统: Windows10 专业版
编译器: GUNstep
代码编程器: Code::Blocks-13.12
资料&书籍: 《Objective-C程序设计》
源码:
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[])
{
NSAutoreleasePool *test=[[NSAutoreleasePool alloc] init];
int row,rowMax;
int count,blankCount;
// BOOL blankOn_off;
// blankOn_off = YES;
printf("Please input row number:");
scanf("%i",&rowMax);
for(row=1;row<=rowMax;row++){
for(blankCount=1;blankCount<=rowMax-row;blankCount++){
printf(" ");
}
for(count=1;count<=row;count++){
if(count==1)
printf("*");
if(count>1)
printf(" *");
}
printf("\n");
}
[test release];
return 0;
}
运行效果图: