把小於20億以下的數字轉換成大寫輸出

2021-09-01 14:36:17 字數 1123 閱讀 3099

//

//  main.m

//  蓋世天地 //

//  created by ibokan on 12-12-21.

//#import

//void strclear(char *str);

//void strclear(char *str)

// //}

int main (int argc, const

char * argv);//

輸出時候用的。

char s[30]; //

求長度時候用的。

sprintf(s, "%d", temp);//

整型轉化為字串。

int len=strlen(s);//

隨機數字的長度。

int i=0;//

從個位數字開始。

char *result[100];//

儲存每位數字結果的字串陣列。

//迴圈從個位數開始把結果存入result陣列中。

int flag=0;//

判斷萬的時候。

int flag2=0;//

判斷億的時候。

while (len>0)

//判斷不是個位數的時候。需要乙個拼接並放到陣列中。

if (i>0)

if (flag==1)

if (strstr(a[9+i], "

萬"))

}else

if (flag2==1)

if (strstr(a[9+i], "

億"))  }}

result[i]=res2;

printf("%s*****=\n",result[i]);//

此時輸出的是正常的:五十,二百,四千。 }

i++;

len--;

temp=temp/10;   

}if (i==1)

else

else

if((strcmp(result[i-1], "

零")!=0))

i--;

}if ((i==1)&&(strcmp(result[0], "

零")!=0)) }}

return0;}

把純數字轉換成大寫的數字

把數字轉成大寫的數字 function imgcount num 驗證輸入的字元是否為數字 if isnan num 字元處理完畢後開始轉換,採用前後兩部分分別轉換 小數點為界限 part string num split 初始化乙個字串 newchar 小數點前進行轉化 for i part 0 ...

數字轉換成大寫金額

數字轉換成大寫金額 using system public class numtocaps 將數定轉換大寫金額格式 引數必須小於萬萬億,且不超過兩位小數多過兩位自動擷取兩位 返回大寫金額 public string getcaps decimal d if d 0 if s.length 0 s.l...

數字轉換成大寫金額

數字轉換成大寫金額 例如 new money 200 tostring 貳佰元 namespace skyiv.util catch system.console.writeline 大寫 newmoney m 該類過載的 tostring 方法返回的是大寫金額字串 class money 建構函式...