RMB amount case transformation

xiaoxiao2021-03-06  66

When you write a procedure involving the amount, sometimes you need to convert your lower-write RMB amount into uppercase indicating that the code below shows the implementation process of the conversion. You can refer to it! #Pragma Warning (Disable: 4786) #include #include #include #include

Using std :: string; using st: cout; using st :: cin; using st ::

String ConvertMoney (double dnum) {string strresult; // To return string char c_digit [20]; // C style character array string strdigit; // Enter the numeric string

INT iLENGTH = 0; // Input double precision number length INT IADDZERO = 0; // 加零 加 =it ​​= 0; // Removed Digital

String str1 [] = {"points", "angle", "yuan", "pick", "", "仟", "万", "", "", "100 million", "Picking", "", "仟", "10,000", "", "", "仟"}; string str2 [] = {"zero", "", "贰", "" , "", "Wu", "Lu", "柒", "捌", "玖"}

Vector Strunit (STR1, STR1 18); // Initialization Vector Vector StrupPernum (STR2, STR2 10);

Sprintf (c_digit, "%. 0f", dnum * 100); // convert the number string to the array strdigit = c_digit; // assign the content of the character array to the String variable

iLength = strdigit.length (); // Take the length of the string

IF (iLength> 15 || ilength <0) // If the input number exceeds the length of Double type data returns "error" return "error"; for (int i = 0; i 0) // If the current is not 0, and add 0 flags greater than 0 strRRRESULT = "zero"; // add "zero" strRRESULT = StrupPernum [iDigit] in the string; ipdzero = 0; } // This position is not 0 || Distance ||||||| "(iDigit! = 0) || (ilength - i == 3) || (ilength - i == 11) || ((ilength - i 1)% 8 == 0 && (Iaddzero <4))) Strresult = Strunit [ILENGTH - I - 1];} IF (strdigit.substr (strdigit.length () - 2, 2) == "00") Strresult = "õû"; return strresult;} int main () {double DLOWERRMB = 0.0; cout << "Please enter the amount of RMB that you want to convert!" << Endl; cin >> DLowerRMB; cout << "--------------------------------------------------------------- - "<< endl; cout <<" You want to convert the RMB lowercase amount is "<<" / n "<< DLOWERRMB << Endl; cout << ------------------------------------- "<< endl; string strunerrmb = communicationMoney (DLOWERRMB); cout <<" 大 大 金 额 "<<" / n "<< StrupPerRMB << Endl; cout <<< ------------ ------------------------------------ "<< Endl; return 0;} If you are not used to With the String class in standard C , you can use the cstring in the MFC to replace String!

转载请注明原文地址:https://www.9cbs.com/read-84086.html

New Post(0)