#import <Foundation/Foundation.h>
int main (int argc, const char * argv[]) {
@autoreleasepool {
1. There are 123456789, how to put the number of each digit, starting at the end of a sequence into an array
(then the first element of this new array is 9, one time and so on) if you succeed, walk them out.
NSNumber *[email protected];
Nsarray *[email protected][@ "1", @ "2", @ "3", @ "4", @ "5", @ "6", @ "7", @ "8", @ "9"];
NSString *str=[nsstring stringwithformat:@ "%@", Num];
Nsmutablearray *mutarr=[nsmutablearray Array];
for (int i=8; i>=0; i--) {
Nsrange RANG0;
Rang0.location=i;
rang0.length=1;
NSString *str1=[[nsstring Alloc]init];
Str1=[str SUBSTRINGWITHRANGE:RANG0];
[Mutarr ADDOBJECT:STR1];
}
For (id xin in Mutarr) {
NSLog (@ "%@", Xin);
}
NSLog (@ "????????????????????????????????????????????????????????");
2. How to invert the string @ "abc123xyz789"
NSString *[email protected] "abc123.xyz789";
Nsmutablestring * mutstr1=[nsmutablestring string];
for (int i=0; i<strd.length; i++) {
Unichar C=[STRD Characteratindex:strd.length-i-1];
[Mutstr1 appendformat:@ "%c", c];
}
STR=MUTSTR1;
NSLog (@ "%@", str);
NSLog (@ "????????????????????????????????????????????????????????");
NSString *[email protected] "May 05, 2013";
Nsrange rang;
rang.location=0;
rang.length=4;
NSString *new=[time Substringwithrange:rang];
NSLog (@ "%@", new);
Nsrange rang1;
rang1.location=8;
rang1.length=2;
NSString *new1=[time Substringwithrange:rang1];
NSLog (@ "%@", New1);
Nsrange rang2;
rang2.location=8;
rang2.length=2;
NSString *new2=[time Substringwithrange:rang2];
NSLog (@ "%@", new2);
NSString *newstr=[new stringbyappendingformat:@ "-%@-%@", new1,new2];
NSLog (@ "%@", newstr);
}
return 0;
}
integer int, reverse string