91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

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

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

字符串分割小例子

發布時間: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

社旗县| 临高县| 治县。| SHOW| 镇赉县| 宜春市| 麻城市| 茌平县| 九台市| 类乌齐县| 霍邱县| 萨迦县| 金坛市| 永川市| 岳普湖县| 孝感市| 武隆县| 宜良县| 金昌市| 皮山县| 建水县| 布拖县| 博白县| 射洪县| 绥芬河市| 姜堰市| 新乐市| 山丹县| 资中县| 突泉县| 锡林郭勒盟| 苏尼特左旗| 冀州市| 年辖:市辖区| 三亚市| 海宁市| 达孜县| 洞头县| 钟山县| 景东| 武乡县|