面试题答案
一键面试#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]) {
@autoreleasepool {
NSInteger score;
NSLog(@"请输入成绩(0 - 100):");
scanf("%ld", &score);
if (score < 0 || score > 100) {
NSLog(@"输入成绩不合法,请输入0到100之间的数字。");
} else if (score >= 90) {
NSLog(@"评级为'A'");
} else if (score >= 80) {
NSLog(@"评级为'B'");
} else if (score >= 70) {
NSLog(@"评级为'C'");
} else if (score >= 60) {
NSLog(@"评级为'D'");
} else {
NSLog(@"评级为'F'");
}
}
return 0;
}