共7条回复
楼长
·
geekbao
回复于 2014年08月31日
代码贴上来
2楼
·
boho
回复于 2014年08月31日
import <Foundation/Foundation.h>
//打印每月的天数 int main (int argc, char *argv[]) { @autoreleasepool { enum month { january = 1, february, march, april, may, june, july, august, september, october, november, december }; enum month amonth; int days;
NSLog(@"Enter month number: ");
scanf("%i", &amonth);
switch (amonth)
{
case january:
case march:
case may:
case july:
case august:
case october:
case december:
days = 31;
break;
case april:
case june:
case september:
case november:
days = 30;
break;
case february:
days = 28;
break;
default:
NSLog(@"bad month number");
days = 0;
break;
}
if (days != 0)
NSLog(@"Number of days is %i", days);
if (amonth == february)
{
NSLog(@"...or 29 if it's a leap year");
}
}
return 0;
}
3楼
·
tinyfool
回复于 2014年08月31日
scanf在Cocoa编程里面几乎不会遇到,什么教程还有这个?这个教程可以不看了
4楼
·
boho
回复于 2014年08月31日
老大推荐本学cocoa得书吧,我刚开始学objective-c