總結:用有窮狀態自動機寫了個程式,算是對它的複習吧!~其實也是想試試。學到東西還是挺多的,flag標誌來控制是否的變成大寫,以及對非字元的處理狀態" noup ",對字元的處理「up」又分兩類「大寫」和「小寫」。
#include#include#includeusing namespace std;
void upperthefirstletter(string &str)
else if (islower(str[i])||isupper(str[i]))
break;
case noup:
if (isspace(str[i]) || ispunct(str[i]))
else if (islower(str[i]) || isupper(str[i]))
break;
case up:
if (isupper(str[i]))
else if (flag == 1)
else if (isspace(str[i]) || ispunct(str[i]))
break;
} }}void main1()
字串單詞首字母大寫問題
是不是有時候會出現將乙個字串中的每個單詞的首字母大寫化,其餘字元均為小寫的情況,如 hello world 轉化為 hello world 好了接下來大家可以試驗一下是否可以解決這個問題,在這裡我要和大家分享幾種比較容易理解的解決方案。function titlecase str return co...
小tips JS CSS實現字串單詞首字母大寫
css實現 text transform capitalize js 一 string.prototype.firstuppercase function var result i m hello world firstuppercase console.log result i m hello w...
句中單詞首字母大寫的3中姿態
問題解釋 比如function接收乙個字串 hello word 那麼輸出就是 hello word 如果接收的是 hello word 那麼輸出的就是 hello word var str always remember that you are absolutely unique.1 初級程式設...