亚洲激情专区-91九色丨porny丨老师-久久久久久久女国产乱让韩-国产精品午夜小视频观看

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

字符串分割小例子

發布時間:2020-07-24 09:17:09 來源:網絡 閱讀:265 作者:iSanny 欄目:開發技術
一個反向輸出字符串的例子,不用componentsSeparatedByString去實現以空格字符分割字符串然后反向輸出:


#import <Foundation/Foundation.h>

int main(int argc, const char * argv[])
{

        @autoreleasepool {
                
                // insert code here...
                //NSLog(@"Hello, World!");
                NSString *a =[[NSString alloc] initWithFormat:@"I am a good person\n"];
                NSMutableString *letters = [NSMutableString stringWithFormat:@""];
                //NSInteger t = 0;
                for (NSInteger i = a.length-1;i>=0; i--)
                {
                        if([a characterAtIndex:i]==' ')
                        {
                                NSString *temp = [a substringWithRange:NSMakeRange(i+1,a.length-i-1)];
                                //NSLog(@"%@",temp);
                                for(NSInteger j=0;j<temp.length;j++)
                                {
                                        if([temp characterAtIndex:j]==' ' || [temp characterAtIndex:j]=='\n')
                                        {NSString *temp2= [temp substringWithRange:NSMakeRange(0, j)];
                                                [letters appendString:temp2];
                                                [letters appendString:@" "];
                                                //NSLog(@"%@",temp2);
                                                break;
                                        }
                                }
                        }
                        if(i==0)
                        {
                                [letters appendString:[a substringWithRange:NSMakeRange(0,i+1)]];
                        }
                }
        NSLog(@"%@",letters);
        }
        
        return 0;
}

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

毕节市| 普兰店市| 彭泽县| 河西区| 章丘市| 迁安市| 和龙市| 杭锦后旗| 贡觉县| 蓝田县| 曲松县| 抚松县| 阿拉善右旗| 灯塔市| 武定县| 岳阳县| 灵台县| 梧州市| 磐安县| 托克托县| 万荣县| 砚山县| 禹州市| 图片| 龙江县| 泽普县| 襄汾县| 海丰县| 达拉特旗| 淮阳县| 莱州市| 惠州市| 阿拉善左旗| 神农架林区| 沙田区| 安吉县| 秭归县| 峡江县| 平潭县| 分宜县| 彰武县|