////main.m//before 1////Created by Syrcfwzx on 16/1/11.//Copyright (c) 2016 SYRCFWZX. All rights reserved.//#import<Foundation/Foundation.h>#defineNSLog (FORMAT, ...) printf ("%s\n", [[NSString Stringwithformat:format, # #__VA_ARGS__] utf8string])intMainintargcConst Char*argv[]) {@autoreleasepool {/*The 1th question please store the following data into a dictionary, and the dictionary content as a string output, output: "xxx, age xxx, subject xxx, score xxx" (replace XXX with the corresponding data). */NSString*name =@"Zhang San"; Nsinteger Age= A; NSNumber*[email protected]88.7; NSString*subject =@"Mathematics"; Nsdictionary*dic = @{@"name": Name,@" Age": @ (age),@"score": Score,@"subject": Subject}; NSLog (@"%@ %@ %@ %@", dic[@"name"],dic[@" Age"],dic[@"score"],dic[@"subject"]); /*2nd question: 12,9,34,56,11 deposit Nsarray Array, output: 1) Reverse output 2) descending output*/Nsarray*array = [Nsarray arraywithobjects:@ A,@9,@ the,@ About,@ One, nil]; Nsarray*arr = [Array Sortedarrayusingcomparator:^nscomparisonresult (IDObj2,IDobj1) { return[Obj1 Compare:obj2]; }]; NSLog (@"%@", arr); Nsarray*ARR2 = [Array sortedarrayusingselector: @selector (class)]; NSLog (@"%@", ARR2); //4th The elements in the array are sorted by Chinese//nsarray *[email protected][@ "Light Rain", @ "Ann", @ "small wind", @ "Rongrong", @ "Zhang Tao" @ "Li Wenrong"]; //nsarray *arrr=[arr sortedarrayusingselector: @selector (localizedstandardcompare:)]; //For (id ser in arrr) {//NSLog (@ "%@", Ser); // }Nsarray *[email protected][@"Light Rain",@"Ann",@"Xiao Feng",@"Rongrong",@"Zhang Tao",@"Li Wenrong"]; Nsarray*sortarr = [Arr5 sortedarrayusingcomparator:^nscomparisonresult (IDObj1,IDobj2) { return[Obj1 Localizedcompare:obj2]; }]; for(IDObjinchSortarr) {NSLog (@"%@", obj); } } return 0;}
Chinese sort haha