#importstatic NSString * const kName = @"name";static NSString * const kAge = @"age";static NSString * const kGender = @"gender";inline static NSMutableDictionary *CreateDict(NSString *name, NSInteger age, BOOL isMale){ NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithDictionary:@{kName:name,kAge :@(age),kGender :@(isMale)}]; return dict;}int main(int argc, const char * argv[]) { @autoreleasepool { NSArray *array = @[CreateDict(@"王思聪", 27, YES), CreateDict(@"范冰冰", 35, NO), CreateDict(@"马云", 51, YES), CreateDict(@"霍建华", 36, YES), CreateDict(@"赵丽颖", 28, NO)]; //第1题 请按照年龄的升序排序输出,输出样式为:王思聪,男性,今年27岁 NSLog(@"第一题"); NSArray *newarr=[array sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) { return [obj1[kAge] compare:obj2[kAge]]; }]; for (NSDictionary *str in newarr) { //BOOL result=[str[kGender] boolValue]; if (![str[kGender]isEqual:@YES]) { NSLog(@"%@,女性,今年%@",str[kName],str[kAge]); } else{ NSLog(@"%@,男性,今年%@",str[kName],str[kAge]); } } //第2题 请输出女性信息,输出样式为:范冰冰大美女,今年35岁 NSLog(@"第二题"); for (id str1 in newarr) { BOOL result1=[str1[kGender] boolValue]; if (!result1){ NSLog(@"%@大美女,今年%@",str1[kName],str1[kAge]); } } //第3题 请将“马云”的年龄改为41岁 NSLog(@"第三题"); // NSMutableArray *muarr=[NSMutableArray array]; for (int i=0; i