1-9 作业1

//
//  main.m
//  作业1
//
//  Created by syrcfwzx on 16/1/9.
//  Copyright (c) 2016年 syrcfwzx. All rights reserved.
//

#import <Foundation/Foundation.h>
#define NSLog(FORMAT, ...) printf("%s\n", [[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String])
int main(int argc, const char * argv[]) {
    @autoreleasepool {
        
        NSNumber* num = [NSNumber numberWithInt:123456789];
        NSString* str = [NSString stringWithFormat:@"%@",num];
        //NSMutableString* reverse = [NSMutableString string];
        NSMutableArray* array = [NSMutableArray array];
        NSInteger len = [str length];
        for(NSInteger i=len-1;i>=0;i--)
        {
            unichar c = [str characterAtIndex:i];
            NSString* temp = [NSString stringWithCharacters:&c length:1];
            [array addObject:temp];
        }
        for(id obj in array)
        {
            NSLog(@"%@",obj);
        }
       NSLog(@"🍀🍀🍀🍀🍀🍀🍀🍀🍀🍀🍀🍀🍀🍀🍀🍀🍀🍀🍀");
        NSMutableArray* arr = [NSMutableArray array];
        for(NSInteger i =str.length-1;i>=0;i--)
        {
            NSString* str4 = [str substringWithRange:NSMakeRange(i, 1)];
            [arr addObject:str4];
        }
        for(id obj in arr)
        {
            NSLog(@"%@",obj);
        }

        
        
    }
    return 0;
}

 

posted @ 2016-01-09 14:51  33sve  阅读(121)  评论(0编辑  收藏  举报