能被4整除但不能被100整除或者能被400整除
#import <Foundation/Foundation.h>
int main(int agrc, const char * argv[]) {
@autoerleasepool {
int year = 2100;
if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) {
NSLog (@"%i is a leap year", year);
} else {
NSLog (@"%i is not a leap year", year);
}
}
return 0;
}
网友评论