//
// main.m
// 根据出生日期计算星座
//
// Created by lichan on 13-11-28.
// Copyright (c) 2013年 com.lichan. All rights reserved.
//
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[])
{
@autoreleasepool {
char birthday[20];
printf("请输入你的出生日期(阳历)(格式:yyyymmdd):");
scanf("%s",birthday);
NSString *ymd = [[NSString alloc]initWithUTF8String:birthday];
// NSString *md = [ymd substringFromIndex:4];
NSRange monthRange ;
monthRange.length = 2;
monthRange.location = 4;
NSString *month = [ymd substringWithRange:monthRange];
int intMonth = [month intValue];
// NSLog(@"%d",[month intValue]);
//--------------------
NSRange dayRange ;
dayRange.length = 2;
dayRange.location = 6;
NSString *day = [ymd substringWithRange:dayRange];
int intDay = [day intValue];
// NSLog(@"day:%@",day);
switch (intMonth) {
case 1:
{
if (intDay <= 19)
NSLog(@"你是 魔蝎座.");
else
NSLog(@"你是 水瓶座.");
break;
}
case 2:
{
if (intDay <= 18)
NSLog(@"你是 水瓶座.");
else
NSLog(@"你是 双鱼座.");
break;
}
case 3:
{
if (intDay <= 20)
NSLog(@"你是 双鱼座.");
else
NSLog(@"你是 白羊座.");
break;
}
case 4:
{
if (intDay <= 19)
NSLog(@"你是 白羊座.");
else
NSLog(@"你是 金牛座.");
break;
}
case 5:
{
if (intDay <= 20)
NSLog(@"你是 金牛座.");
else
NSLog(@"你是 双子座.");
break;
}
case 6:
{
if (intDay <= 21)
NSLog(@"你是 双子座.");
else
NSLog(@"你是 巨蟹座.");
break;
}
case 7:
{
if (intDay <= 22)
NSLog(@"你是 巨蟹座.");
else
NSLog(@"你是 狮子座.");
break;
}
case 8:
{
if (intDay <= 22)
NSLog(@"你是 狮子座.");
else
NSLog(@"你是 处女座.");
break;
}
case 9:
{
if (intDay <= 22)
NSLog(@"你是 处女座.");
else
NSLog(@"你是 天秤座.");
break;
}
case 10:
{
if (intDay <= 23)
NSLog(@"你是 天秤座.");
else
NSLog(@"你是 天蝎座.");
break;
}
case 11:
{
if (intDay <= 22)
NSLog(@"你是 天蝎座.");
else
NSLog(@"你是 射手座.");
break;
}
case 12:
{
if (intDay <= 19)
NSLog(@"你是 魔蝎座.");
else
NSLog(@"你是 水瓶座.");
break;
}
default:
break;
}
// insert code here...
}
return 0;
}
//touchdb@sina.com lllm126