ios 开发之--逆序输出字符串

//字符串反转NSString *str = @abcedfghijklmnopqrstuvwxyz;NSMutableString *string = [NSMutableString stringWithCapacity:str.length];int j = (int)str.length;for (int i = j - 1; i=0; i--) {[string appe...

//字符串反转
    NSString *str = @"abcedfghijklmnopqrstuvwxyz";
    NSMutableString *string = [NSMutableString stringWithCapacity:str.length];
    int j = (int)str.length;
    for (int i = j - 1; i>=0; i--) {
        [string appendFormat:@"%c",[str characterAtIndex:i]];
    }
    
    NSLog(@"string is-- %@",string);

输出如下:

string is-- zyxwvutsrqponmlkjihgfdecba

 

仅做记录!

本文标题为:ios 开发之--逆序输出字符串

基础教程推荐