引言
我想討論一下我幾年前在 C++ 中開發的一種程式設計技術,用於將數字金額轉換為文字金額。我將其用於我為家鄉美國俄亥俄州克利夫蘭市的一位長期客戶編寫的支票簿登記簿程式中。這項技術是一個較大程式中的一個模組,該程式用於每週編寫和簽發支票,用於支付工資、稅款、材料、辦公用品、公用事業費用等等。多年來,它被證明非常可靠。該演算法還可以用於協助列印法律合同、貸款檔案、本票以及許多其他需要指定文字金額的事項。
我網站上可以看到完整的 C++ 程式程式碼。接下來,我將解釋邏輯流程,以便於理解。
準備工作
在 C++ 原始碼的開頭,會定義常量,以便其餘程式碼可以引用它們來完成各種任務。點選“列印支票”按鈕後,將宣告變數和物件。接下來,使用簡單的 if-then 邏輯結構來測試是否已從支票簿登記簿螢幕中選擇了一個支票簿登記簿記錄。這是必需的,因為需要支票簿登記簿螢幕中的支票號碼來幫助建立列印的支票。現在初始化支票和支票存根的變數。接下來,從當前顯示螢幕的控制元件中檢索以下項。這些項包括支票號碼、供應商名稱、發票描述、支票備忘錄和付款日期。
下一步,必須開啟到二進位制支票簿登記簿資料檔案“cbook.txt”的檔案流。在這裡,將進入一個 do-while 迴圈結構,以收集要支付的每張發票的資料。每張支票簿登記簿記錄的支票號碼將與當前資料錄入螢幕中檢索到的支票號碼進行匹配。每條匹配的記錄將檢索特定供應商發票的日期、費用程式碼、發票號碼、發票總額、提前付款折扣和淨髮票金額,這些發票將透過此支票支付。在此特定應用程式的支票存根上,最多隻能有 10 張發票。每次透過 do-while 迴圈結構時,匹配的支票簿登記簿記錄將被標記為已付款,並且淨髮票金額將被累加。此總額將成為要轉換為文字金額的數字金額。
在驗證從上面的 do-while 迴圈結構中至少找到一個匹配的支票號碼後,淨髮票金額總額將在一個名為“totpay”的字元陣列中指定。該字元陣列將在片刻的轉換到文字金額中得到廣泛利用。但首先,必須開啟到供應商二進位制資料檔案“vendor.txt”的檔案流。這將是另一個 do-while 迴圈結構,它將當前顯示螢幕中檢索到的供應商名稱與供應商資料檔案中的名稱進行匹配。供應商的街道、城市、州和郵政編碼將在成功匹配後檢索,然後使用一些簡單的字串操作進行格式化,以便最終列印在支票上。
核心部分
這裡有一些字元陣列集,它們定義了用於構建支票文字金額的某些文字元件。這些字元陣列集中的每一個都將被分配一個特定的名稱,以便敘述利用它們將數字金額轉換為文字金額的軟體開發演算法。
1 2 3 4 5 6 7 8 9 10
|
char am1[] = "NINETY";
char am2[] = "EIGHTY";
char am3[] = "SEVENTY";
char am4[] = "SIXTY";
char am5[] = "FIFTY";
char am6[] = "FORTY";
char am7[] = "THIRTY";
char am8[] = "TWENTY";
|
上述字元陣列內容根據要轉換的數字金額小數點左側的第二(2nd)和第五(5th)位數字,選擇性地連線到文字描述變數。
這是 A 組。
1 2 3 4 5 6 7 8 9 10 11
|
char am9[] = "ONE";
char am10[] = "TWO";
char am11[] = "THREE";
char am12[] = "FOUR";
char am13[] = "FIVE";
char am14[] = "SIX";
char am15[] = "SEVEN";
char am16[] = "EIGHT";
char am17[] = "NINE";
|
上述字元陣列內容根據要轉換的數字金額小數點左側的第一(1st)、第三(3rd)和第四(4th)位數字,選擇性地連線到文字描述變數。
這是 B 組。
1 2 3
|
char am18[] = "THOUSAND";
|
在檢測到“千位數字”(即要轉換的數字金額小數點左側的第四(4th)位)之後,將其連線到文字描述變數。
這是千位指示符。
1 2 3
|
char am19[] = "HUNDRED";
|
在檢測到“百位數字”(即要轉換的數字金額小數點左側的第三(3rd)位)之後,將其連線到文字描述變數。
這是百位指示符。
此項不連線到文字描述變數,而是在處理結束時,在沒有其他描述符連線到上述變數後為其賦值。
這是零指示符。
1 2 3 4 5 6 7 8 9 10 11 12
|
char am210[] = "TEN";
char am211[] = "ELEVEN";
char am212[] = "TWELVE";
char am213[] = "THIRTEEN";
char am214[] = "FOURTEEN";
char am215[] = "FIFTEEN";
char am216[] = "SIXTEEN";
char am217[] = "SEVENTEEN";
char am218[] = "EIGHTEEN";
char am219[] = "NINETEEN";
|
上述字元陣列內容根據要轉換的數字金額小數點左側的第一(1st)和第四(4th)位數字,選擇性地連線到文字描述變數。
這是 C 組。
開始構建
首先要做的就是用空格字元初始化 70 個字元的字元陣列“verbal_amount”,以便演算法將其更新,該演算法將字元陣列“totpay”中的數字金額轉換為對應的文字金額。還將使用一個計數器變數“aa”來計算附加到字元陣列“verbal_amount”中的字元數。
接下來,檢查數字字元陣列“totpay”中小數點左側的第 5 位數字是否大於 0(開始結構“a”)。如果為真,則檢查數字字元陣列“totpay”中小數點左側的第 5 位數字是否等於 1(開始結構“b”)。如果為真,則使用 **C 組** 根據數字字元陣列“totpay”中小數點左側的第 4 位數字,為“verbal_amount”字元陣列分配描述符,如下所示。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
// if the 4th digit to the left of the decimal point is 0, then append
// "TEN" to the 'verbal_amount' array.
if(totpay[3] == 48) {
for(f=0; f<3; f++) verbal_amount[f] = am210[f];
aa=3;
}
// if the 4th digit to the left of the decimal point is 1, then append
// "ELEVEN" to the 'verbal_amount' array.
if(totpay[3] == 49) {
for(f=0; f<6; f++) verbal_amount[f] = am211[f];
aa=6;
}
// if the 4th digit to the left of the decimal point is 2, then append
// "TWELVE" to the 'verbal_amount' array.
if(totpay[3] == 50) {
for(f=0; f<6; f++) verbal_amount[f] = am212[f];
aa=6;
}
// if the 4th digit to the left of the decimal point is 3, then append
// "THIRTEEN" to the 'verbal_amount' array.
if(totpay[3] == 51) {
for(f=0; f<8; f++) verbal_amount[f] = am213[f];
aa=8;
}
// if the 4th digit to the left of the decimal point is 4, then append
// "FOURTEEN" to the 'verbal_amount' array.
if(totpay[3] == 52) {
for(f=0; f<8; f++) verbal_amount[f] = am214[f];
aa=8;
}
// if the 4th digit to the left of the decimal point is 5, then append
// "FIFTEEN" to the 'verbal_amount' array.
if(totpay[3] == 53) {
for(f=0; f<7; f++) verbal_amount[f] = am215[f];
aa=7;
}
// if the 4th digit to the left of the decimal point is 6, then append
// "SIXTEEN" to the 'verbal_amount' array.
if(totpay[3] == 54) {
for(f=0; f<7; f++) verbal_amount[f] = am216[f];
aa=7;
}
// if the 4th digit to the left of the decimal point is 7, then append
// "SEVENTEEN" to the 'verbal_amount' array.
if(totpay[3] == 55) {
for(f=0; f<9; f++) verbal_amount[f] = am217[f];
aa=9;
}
// if the 4th digit to the left of the decimal point is 8, then append
// "EIGHTEEN" // to the 'verbal_amount' array.
if(totpay[3] == 56) {
for(f=0; f<8; f++) verbal_amount[f] = am218[f];
aa=8;
}
// if the 4th digit to the left of the decimal point is 9, then append
// "NINETEEN" // to the 'verbal_amount' array.
if(totpay[3] == 57) {
for(f=0; f<8; f++) verbal_amount[f] = am219[f];
aa=8;
}
|
結束結構“b”。接下來,使用 **A 組** 根據數字字元陣列“totpay”中小數點左側的第 5 位數字,為“verbal_amount”字元陣列分配描述符,如下所示。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
// if the 5th digit to the left of the decimal point is 2, then append
// "TWENTY" to the 'verbal_amount' array.
if(totpay[2] == 50) {
for(f=0; f<6; f++) verbal_amount[f] = am8[f];
aa=6;
}
// if the 5th digit to the left of the decimal point is 3, then append
// "THIRTY" to the 'verbal_amount' array.
if(totpay[2] == 51) {
for(f=0; f<6; f++) verbal_amount[f] = am7[f];
aa=6;
}
// if the 5th digit to the left of the decimal point is 4, then append
// "FORTY" to the 'verbal_amount' array.
if(totpay[2] == 52) {
for(f=0; f<5; f++) verbal_amount[f] = am6[f];
aa=5;
}
// if the 5th digit to the left of the decimal point is 5, then append
// "FIFTY" to the 'verbal_amount' array.
if(totpay[2] == 53) {
for(f=0; f<5; f++) verbal_amount[f] = am5[f];
aa=5;
}
// if the 5th digit to the left of the // decimal point is 6, then append
// "SIXTY" to the 'verbal_amount' array.
if(totpay[2] == 54) {
for(f=0; f<5; f++) verbal_amount[f] = am4[f];
aa=5;
}
// if the 5th digit to the left of the decimal point is 7, then append
// "SEVENTY" to the 'verbal_amount' array.
if(totpay[2] == 55) {
for(f=0; f<7; f++) verbal_amount[f] = am3[f];
aa=7;
}
// if the 5th digit to the left of the decimal point is 8, then append
// "EIGHTY" to the 'verbal_amount' array.
if(totpay[2] == 56) {
for(f=0; f<6; f++) verbal_amount[f] = am2[f];
aa=6;
}
// if the 5th digit to the left of the decimal point is 9, then append
// "NINETY" to the 'verbal_amount' array.
if(totpay[2] == 57) {
for(f=0; f<6; f++) verbal_amount[f] = am1[f];
aa=6;
}
|
開始結構“c”。如果數字字元陣列“totpay”中小數點左側的第 5 位數字不等於 1,則使用 **B 組** 根據數字字元陣列“totpay”中小數點左側的第 4 位數字,為“verbal_amount”字元陣列分配描述符,如下所示。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
// if the 4th digit to the left of the decimal point is 1, then append
// "ONE" to the 'verbal_amount' array.
if(totpay[3] == 49) {
for(f=0; f<3; f++) verbal_amount[f+aa+1] = am9[f];
aa=aa+4;
}
// if the 4th digit to the left of the decimal point is 2, then append
// "TWO" to the 'verbal_amount' array.
if(totpay[3] == 50) {
for(f=0; f<3; f++) verbal_amount[f+aa+1] = am10[f];
aa=aa+4;
}
// if the 4th digit to the left of the decimal point is 3, then append
// "THREE" to the 'verbal_amount' array.
if(totpay[3] == 51) {
for(f=0; f<5; f++) verbal_amount[f+aa+1] = am11[f];
aa=aa+6;
}
// if the 4th digit to the left of the decimal point is 4, then append
// "FOUR" to the 'verbal_amount' array.
if(totpay[3] == 52) {
for(f=0; f<4; f++) verbal_amount[f+aa+1] = am12[f];
aa=aa+5;
}
// if the 4th digit to the left of the decimal point is 5, then append
// "FIVE" to the 'verbal_amount' array.
if(totpay[3] == 53) {
for(f=0; f<4; f++) verbal_amount[f+aa+1] = am13[f];
aa=aa+5;
}
// if the 4th digit to the left of the decimal point is 6, then append
// "SIX" to the 'verbal_amount' array.
if(totpay[3] == 54) {
for(f=0; f<3; f++) verbal_amount[f+aa+1] = am14[f];
aa=aa+4;
}
// if the 4th digit to the left of the decimal point is 7, then append
// "SEVEN" to the 'verbal_amount' array.
if(totpay[3] == 55) {
for(f=0; f<5; f++) verbal_amount[f+aa+1] = am15[f];
aa=aa+6;
}
// if the 4th digit to the left of the decimal point is 8, then append
// "EIGHT" to the 'verbal_amount' array.
if(totpay[3] == 56) {
for(f=0; f<5; f++) verbal_amount[f+aa+1] = am16[f];
aa=aa+6;
}
// if the 4th digit to the left of the decimal point is 9, then append
// "NINE" to the 'verbal_amount' array.
if(totpay[3] == 57) {
for(f=0; f<4; f++) verbal_amount[f+aa+1] = am17[f];
aa=aa+5;
}
|
結束結構“c”。接下來,將“THOUSAND”附加到字元陣列“verbal_amount”並結束結構“a”。
開始結構“d”。如果小數點左側的第 5 位數字小於 1 且小數點左側的第 4 位數字大於 0,則繼續。使用 **B 組** 根據數字字元陣列“totpay”中小數點左側的第 4 位數字,為“verbal_amount”字元陣列分配描述符,如下所示。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
// if the 4th digit to the left of the decimal point is 1, then append
// "ONE" to the 'verbal_amount' array.
if(totpay[3] == 49) {
for(f=0; f<3; f++) verbal_amount[f+aa+1] = am9[f];
aa=aa+4;
}
// if the 4th digit to the left of the decimal point is 2, then append
// "TWO" to the 'verbal_amount' array.
if(totpay[3] == 50) {
for(f=0; f<3; f++) verbal_amount[f+aa+1] = am10[f];
aa=aa+4;
}
// if the 4th digit to the left of the decimal point is 3, then append
// "THREE" to the 'verbal_amount' array.
if(totpay[3] == 51) {
for(f=0; f<5; f++) verbal_amount[f+aa+1] = am11[f];
aa=aa+6;
}
// if the 4th digit to the left of the decimal point is 4, then append
// "FOUR" to the 'verbal_amount' array.
if(totpay[3] == 52) {
for(f=0; f<4; f++) verbal_amount[f+aa+1] = am12[f];
aa=aa+5;
}
// if the 4th digit to the left of the decimal point is 5, then append
// "FIVE" to the 'verbal_amount' array.
if(totpay[3] == 53) {
for(f=0; f<4; f++) verbal_amount[f+aa+1] = am13[f];
aa=aa+5;
}
// if the 4th digit to the left of the decimal point is 6, then append
// "SIX" to the 'verbal_amount' array.
if(totpay[3] == 54) {
for(f=0; f<3; f++) verbal_amount[f+aa+1] = am14[f];
aa=aa+4;
}
// if the 4th digit to the left of the decimal point is 7, then append
// "SEVEN" to the 'verbal_amount' array.
if(totpay[3] == 55) {
for(f=0; f<5; f++) verbal_amount[f+aa+1] = am15[f];
aa=aa+6;
}
// if the 4th digit to the left of the decimal point is 8, then append
// "EIGHT" to the 'verbal_amount' array.
if(totpay[3] == 56) {
for(f=0; f<5; f++) verbal_amount[f+aa+1] = am16[f];
aa=aa+6;
}
// if the 4th digit to the left of the decimal point is 9, then append
// "NINE" to the 'verbal_amount' array.
if(totpay[3] == 57) {
for(f=0; f<4; f++) verbal_amount[f+aa+1] = am17[f];
aa=aa+5;
}
|
接下來,將“THOUSAND”附加到字元陣列“verbal_amount”並結束結構“d”。
開始結構“e”。如果小數點左側的第 3 位數字大於 0,則繼續。使用 **B 組** 根據數字字元陣列“totpay”中小數點左側的第 3 位數字,為“verbal_amount”字元陣列分配描述符,如下所示。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
// if the 3rd digit to the left of the decimal point is 1, then append
// "ONE" to the 'verbal_amount' array.
if(totpay[4] == 49) {
for(f=0; f<3; f++) verbal_amount[f+aa+1] = am9[f];
aa=aa+4;
}
// if the 3rd digit to the left of the decimal point is 2, then append
// "TWO" to the 'verbal_amount' array.
if(totpay[4] == 50) {
for(f=0; f<3; f++) verbal_amount[f+aa+1] = am10[f];
aa=aa+4;
}
// if the 3rd digit to the left of the decimal point is 3, then append
// "THREE" to the 'verbal_amount' array.
if(totpay[4] == 51) {
for(f=0; f<5; f++) verbal_amount[f+aa+1] = am11[f];
aa=aa+6;
}
// if the 3rd digit to the left of the decimal point is 4, then append
// "FOUR" to the 'verbal_amount' array.
if(totpay[4] == 52) {
for(f=0; f<4; f++) verbal_amount[f+aa+1] = am12[f];
aa=aa+5;
}
// if the 3rd digit to the left of the decimal point is 5, then append
// "FIVE" to the 'verbal_amount' array.
if(totpay[4] == 53) {
for(f=0; f<4; f++) verbal_amount[f+aa+1] = am13[f];
aa=aa+5;
}
// if the 3rd digit to the left of the decimal point is 6, then append
// "SIX" to the 'verbal_amount' array.
if(totpay[4] == 54) {
for(f=0; f<3; f++) verbal_amount[f+aa+1] = am14[f];
aa=aa+4;
}
// if the 3rd digit to the left of the decimal point is 7, then append
// "SEVEN" to the 'verbal_amount' array.
if(totpay[4] == 55) {
for(f=0; f<5; f++) verbal_amount[f+aa+1] = am15[f];
aa=aa+6;
}
// if the 3rd digit to the left of the decimal point is 8, then append
// "EIGHT" to the 'verbal_amount' array.
if(totpay[4] == 56) {
for(f=0; f<5; f++) verbal_amount[f+aa+1] = am16[f];
aa=aa+6;
}
// if the 3rd digit to the left of the decimal point is 9, then append
// "NINE" to the 'verbal_amount' array.
if(totpay[4] == 57) {
for(f=0; f<4; f++) verbal_amount[f+aa+1] = am17[f];
aa=aa+5;
}
|
接下來,將“HUNDRED”附加到字元陣列“verbal_amount”並結束結構“e”。
現在檢查數字字元陣列“totpay”中小數點左側的第 2 位數字是否大於 0(開始結構“f”)。如果為真,則檢查數字字元陣列“totpay”中小數點左側的第 2 位數字是否等於 1(開始結構“g”)。如果為真,則使用 **C 組** 根據數字字元陣列“totpay”中小數點左側的第 1 位數字,為“verbal_amount”字元陣列分配描述符,如下所示。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
// if the 1st digit to the left of the decimal point is 0, then append
// "TEN" to the 'verbal_amount' array.
if(totpay[6] == 48) {
for(f=0; f<3; f++) verbal_amount[f+aa+1] = am210[f];
aa = aa + 4;
}
// if the 1st digit to the left of the decimal point is 1, then append
// "ELEVEN" to the 'verbal_amount' array.
if(totpay[6] == 49) {
for(f=0; f<6; f++) verbal_amount[f+aa+1] = am211[f];
aa = aa + 7;
}
// if the 1st digit to the left of the decimal point is 2, then append
// "TWELVE" to the 'verbal_amount' array.
if(totpay[6] == 50) {
for(f=0; f<6; f++) verbal_amount[f+aa+1] = am212[f];
aa = aa + 7;
}
// if the 1st digit to the left of the decimal point is 3, then append
// "THIRTEEN" to the 'verbal_amount' array.
if(totpay[6] == 51) {
for(f=0; f<8; f++) verbal_amount[f+aa+1] = am213[f];
aa = aa + 9;
}
// if the 1st digit to the left of the decimal point is 4, then append
// "FOURTEEN" to the 'verbal_amount' array.
if(totpay[6] == 52) {
for(f=0; f<8; f++) verbal_amount[f+aa+1] = am214[f];
aa = aa + 9;
}
// if the 1st digit to the left of the decimal point is 5, then append
// "FIFTEEN" to the 'verbal_amount' array.
if(totpay[6] == 53) {
for(f=0; f<7; f++) verbal_amount[f+aa+1] = am215[f];
aa = aa + 8;
}
// if the 1st digit to the left of the decimal point is 6, then append
// "SIXTEEN" to the 'verbal_amount' array.
if(totpay[6] == 54) {
for(f=0; f<7; f++) verbal_amount[f+aa+1] = am216[f];
aa = aa + 8;
}
// if the 1st digit to the left of the decimal point is 7, then append
// "SEVENTEEN" to the 'verbal_amount' array.
if(totpay[6] == 55) {
for(f=0; f<9; f++) verbal_amount[f+aa+1] = am217[f];
aa = aa + 10;
}
// if the 1st digit to the left of the decimal point is 8, then append
// "EIGHTEEN" to the 'verbal_amount' array.
if(totpay[6] == 56) {
for(f=0; f<8; f++) verbal_amount[f+aa+1] = am218[f];
aa = aa + 9;
}
// if the 1st digit to the left of the decimal point is 9, then append
// "NINETEEN" to the 'verbal_amount' array.
if(totpay[6] == 57) {
for(f=0; f<8; f++) verbal_amount[f+aa+1] = am219[f];
aa = aa + 9;
}
|
結束結構“g”。接下來,使用 **A 組** 根據數字字元陣列“totpay”中小數點左側的第 2 位數字,為“verbal_amount”字元陣列分配描述符,如下所示。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
// if the 2nd digit to the left of the decimal point is 2, then append
// "TWENTY" to the 'verbal_amount' array.
if(totpay[5] == 50) {
for(f=0; f<6; f++) verbal_amount[f+aa+1] = am8[f];
aa=aa+7;
}
// if the 2nd digit to the left of the decimal point is 3, then append
// "THIRTY" to the 'verbal_amount' array.
if(totpay[5] == 51) {
for(f=0; f<6; f++) verbal_amount[f+aa+1] = am7[f];
aa=aa+7;
}
// if the 2nd digit to the left of the decimal point is 4, then append
// "FORTY" to the 'verbal_amount' array.
if(totpay[5] == 52) {
for(f=0; f<5; f++) verbal_amount[f+aa+1] = am6[f];
aa=aa+6;
}
// if the 2nd digit to the left of the decimal point is 5, then append
// "FIFTY" to the 'verbal_amount' array.
if(totpay[5] == 53) {
for(f=0; f<5; f++) verbal_amount[f+aa+1] = am5[f];
aa=aa+6;
}
// if the 2nd digit to the left of the decimal point is 6, then append
// "SIXTY" to the 'verbal_amount' array.
if(totpay[5] == 54) {
for(f=0; f<5; f++) verbal_amount[f+aa+1] = am4[f];
aa=aa+6;
}
// if the 2nd digit to the left of the decimal point is 7, then append
// "SEVENTY" to the 'verbal_amount' array.
if(totpay[5] == 55) {
for(f=0; f<7; f++) verbal_amount[f+aa+1] = am3[f];
aa=aa+8;
}
// if the 2nd digit to the left of the decimal point is 8, then append
// "EIGHTY" to the 'verbal_amount' array.
if(totpay[5] == 56) {
for(f=0; f<6; f++) verbal_amount[f+aa+1] = am2[f];
aa=aa+7;
}
// if the 2nd digit to the left of the decimal point is 9, then append
// "NINETY" to the 'verbal_amount' array.
if(totpay[5] == 57) {
for(f=0; f<6; f++) verbal_amount[f+aa+1] = am1[f];
aa=aa+7;
}
|
結束結構“f”。如果小數點左側的第 1 位數字大於 0 且小數點左側的第 2 位數字不等於 1,則開始結構“h”。使用 **B 組** 根據數字字元陣列“totpay”中小數點左側的第 1 位數字,為“verbal_amount”字元陣列分配描述符,如下所示。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
// if the 1st digit to the left of the decimal point is 1, then append
// "ONE" to the 'verbal_amount' array.
if(totpay[6] == 49) {
for(f=0; f<3; f++) verbal_amount[f+aa+1] = am9[f];
aa=aa+4;
}
// if the 1st digit to the left of the decimal point is 2, then append
// "TWO" to the 'verbal_amount' array.
if(totpay[6] == 50) {
for(f=0; f<3; f++) verbal_amount[f+aa+1] = am10[f];
aa=aa+4;
}
// if the 1st digit to the left of the decimal point is 3, then append
// "THREE" to the 'verbal_amount' array.
if(totpay[6] == 51) {
for(f=0; f<5; f++) verbal_amount[f+aa+1] = am11[f];
aa=aa+6;
}
// if the 1st digit to the left of the decimal point is 4, then append
// "FOUR" to the 'verbal_amount' array.
if(totpay[6] == 52) {
for(f=0; f<4; f++) verbal_amount[f+aa+1] = am12[f];
aa=aa+5;
}
// if the 1st digit to the left of the decimal point is 5, then append
// "FIVE" to the 'verbal_amount' array.
if(totpay[6] == 53) {
for(f=0; f<4; f++) verbal_amount[f+aa+1] = am13[f];
aa=aa+5;
}
// if the 1st digit to the left of the decimal point is 6, then append
// "SIX" to the 'verbal_amount' array.
if(totpay[6] == 54) {
for(f=0; f<3; f++) verbal_amount[f+aa+1] = am14[f];
aa=aa+4;
}
// if the 1st digit to the left of the decimal point is 7, then append
// "SEVEN" to the 'verbal_amount' array.
if(totpay[6] == 55) {
for(f=0; f<5; f++) verbal_amount[f+aa+1] = am15[f];
aa=aa+6;
}
// if the 1st digit to the left of the decimal point is 8, then append
// "EIGHT" to the 'verbal_amount' array.
if(totpay[6] == 56) {
for(f=0; f<5; f++) verbal_amount[f+aa+1] = am16[f];
aa=aa+6;
}
// if the 1st digit to the left of the decimal point is 9, then append
// "NINE" to the 'verbal_amount' array.
if(totpay[6] == 57) {
for(f=0; f<4; f++) verbal_amount[f+aa+1] = am17[f];
aa=aa+5;
}
|
結束結構“h”。如果上述程式碼中沒有任何內容被轉換為文字金額(由於上述連線程式設計未遞增,“aa”計數器變數等於 0),則將 **零指示符** 賦值給“verbal_amount”字元陣列。最後,在“verbal_amount”字元陣列中跳過一個空格字元,然後附加“AND”。再跳過一個空格字元,然後附加數字字元陣列“totpay”中的兩位(2)分位字元,後跟“/100”。
結論
從上述敘述可以看出,應用程式開發可以節省大量時間和勞動力。當 tôi 建立軟體時,我並不太在意它是否美觀,只要它易於使用、可靠且速度合理即可。這才是商務人士真正關心的。我的開發者技能可以追溯到 20 世紀 90 年代初,當時 tôi 就開始設計商務軟體。如果您想了解更多 về tôi 提供的服務,請透過 tôi 的軟體開發商網站與 tôi 聯絡。