#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]) {
@autoreleasepool {
//1.有个数 123456789,如何将这个数每一位数,从末尾开始依次放入一个数组中
//(那么这个新的数组的第一位元素9,一次类推)如果你成功了,将他们遍历出来
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.如何将字符串@“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]"2013年05月05日";
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;
}