#import
int main(int argc, const char * argv[])
{
@autoreleasepool {
NSMutableString *mutablestring;
char s[15];
NSLog(@"请输入你的出生年月日,格式:yyyymmdd");
scanf("%s",s);
mutablestring = [NSString stringWithFormat:@"%s",s];
NSString *birthday = [mutablestring substringFromIndex:4];
NSLog(@"birthday =%@",birthday);
NSString * first1=[NSString stringWithFormat:@"0120"],*last1=[NSString stringWithFormat:@"0218"];//水平座范围
NSString * first2=[NSString stringWithFormat:@"0219"],*last2=[NSString stringWithFormat:@"0320"];//双鱼座
NSString * first3=[NSString stringWithFormat:@"0321"],*last3=[NSString stringWithFormat:@"0419"];//白羊座
NSString * first4=[NSString stringWithFormat:@"0420"],*last4=[NSString stringWithFormat:@"0520"];//金牛座
NSString * first5=[NSString stringWithFormat:@"0521"],*last5=[NSString stringWithFormat:@"0621"];//双子座
NSString * first6=[NSString stringWithFormat:@"0622"],*last6=[NSString stringWithFormat:@"0722"];//巨蟹座
NSString * first7=[NSString stringWithFormat:@"0723"],*last7=[NSString stringWithFormat:@"0822"];//狮子座
NSString * first8=[NSString stringWithFormat:@"0823"],*last8=[NSString stringWithFormat:@"0922"];//处女座
NSString * first9=[NSString stringWithFormat:@"0923"],*last9=[NSString stringWithFormat:@"1023"];//天秤座
NSString * first10=[NSString stringWithFormat:@"1024"],*last10=[NSString stringWithFormat:@"1122"];//天蝎座
NSString * first11=[NSString stringWithFormat:@"1123"],*last11=[NSString stringWithFormat:@"1221"];//射手座
NSString * first12=[NSString stringWithFormat:@"1222"],*last12=
[NSString stringWithFormat:@"1231"];
NSString *first13=[NSString stringWithFormat:@"0101"] , *last13=[NSString stringWithFormat:@"0119"];//魔蝎座
if ([birthday compare:first1]==NSOrderedDescending&&[birthday compare:last1]==NSOrderedAscending) {
NSLog(@"你是水平座");
}
if ([birthday compare:first2]==NSOrderedDescending&&[birthday compare:last2]==NSOrderedAscending) {
NSLog(@"你是双鱼座");
}
if ([birthday compare:first3]==NSOrderedDescending&&[birthday compare:last3]==NSOrderedAscending) {
NSLog(@"你是白羊座");
}
if ([birthday compare:first4]==NSOrderedDescending&&[birthday compare:last4]==NSOrderedAscending) {
NSLog(@"你是金牛座");
}
if ([birthday compare:first5]==NSOrderedDescending&&[birthday compare:last5]==NSOrderedAscending) {
NSLog(@"你是双子座");
}
if ([birthday compare:first6]==NSOrderedDescending&&[birthday compare:last6]==NSOrderedAscending) {
NSLog(@"你是巨蟹座");
}
if ([birthday compare:first7]==NSOrderedDescending&&[birthday compare:last7]==NSOrderedAscending) {
NSLog(@"你是狮子座");
}
if ([birthday compare:first8]==NSOrderedDescending&&[birthday compare:last8]==NSOrderedAscending) {
NSLog(@"你是处女座");
}
if ([birthday compare:first9]==NSOrderedDescending&&[birthday compare:last9]==NSOrderedAscending) {
NSLog(@"你是天秤座");
}
if ([birthday compare:first10]==NSOrderedDescending&&[birthday compare:last10]==NSOrderedAscending) {
NSLog(@"你是天蝎座");
}
if ([birthday compare:first11]==NSOrderedDescending&&[birthday compare:last11]==NSOrderedAscending) {
NSLog(@"你是射手座");
}
if ([birthday compare:first12]==NSOrderedDescending&&[birthday compare:last12]==NSOrderedAscending) {
NSLog(@"你是魔蝎座");
}
if ([birthday compare:first13]==NSOrderedDescending&&[birthday compare:last13]==NSOrderedAscending) {
NSLog(@"你是魔蝎座");
}
}
return 0;
}