把乙個有規律的字串分成一句話,首字母大寫其他小寫

2021-07-04 09:58:03 字數 510 閱讀 4418

給定乙個字串,按單詞分開,單詞是全大寫或全小寫,

轉換時首字母大寫,其餘全部轉換為小寫,並用空格隔開(15分)

傳入:@"wherethereisawillthereisaway"

返回:@"where there is a will there is a way"

*/-(nsstring *)printbyword:(nsstring *)str

}//    nslog(@"heheh=%c",([mustr characteratindex:0]-32) );

//for迴圈來遍歷字串,獲取字串的每乙個字元判斷大小寫

for (int i = 1; i < mustr.length; i++)

//判斷除了第乙個字元之後的字元,如果為大寫則換成小寫

if ([mustr characteratindex:i] >= 'a'&&[mustr characteratindex:i]<='z')

}return mustr;

}

判讀一句話裡面是否有指定的字串

1.字串中必須僅有p,a,t這三種字元,不可以包含其它字元 2.任意形如 xpatx 的字串都可以獲得 答案正確 其中 x 或者是空字串,或者是僅由字母 a 組成的字串 3.如果 apbtc 是正確的,那麼 apbatca 也是正確的,其中 a,b,c 均或者是空字串,或者是僅由字母 a 組成的字串...

一句話的perl

zcat perl e while 1.hello world 還是從最經典的 hello,world 開始.perl e print hello,world n hello,world 完全不出意料,他沒有任何歧異的終於我們願意的輸出了 hello,world 自然得就像我麼用echo或 prin...

一句話的經典

老外的 的確更精練管用!2.比如 交換word,longint的位元組順序,以便檔案的讀寫 直接用swap支援word longint用 swap bytes for big to littleendian conversion function swap32 along longint longi...