Use C # to implement Arabic digital to uppercase Chinese conversion - second method

xiaoxiao2021-03-06  40

Transfer from: http://blog.9cbs.net/yick/archive/2005/01/12/250097.aspx This is the source code of the class.

Namespace consoleapp {///

/// This class implements arabic number to uppercase translation /// This class does not discriminate illegitimate numbers /// Please call NumTochn Method /// public class NumFormat {Public NumFormat () {// // Todo: Add Constructor Logic //} // Convert Digital Private Char Tonum (CHAR X) {String Strectnnames = "Zero March 3456"; String strnumnames = "0123456789"; returnction strchnnnames [strnumnames.indexof (x)];} // converts universal following integer private string change (string x) {string [] strartrayLevelNames = new string [4] {"," ten " , "Hundred", "Thousand"}; string ret = ""; INT i; for (i = x.length-1; i> = 0; I -) IF (x [i] == '0') Ret = tonum (x [i]) ret; else ret = tonum (x [i]) struntagelevelNames [x.length-1-i] ret; while ((i = ret.indexof ("zero zero") )! = - 1) RET = RET.Remove (I, 1); if (Ret [Ret.Length-1] == 'zero' && Ret.Length> 1) RET = RET.REMOVE (Ret.Length-1 , 1); if (ret.length> = 2 && ret.substring (0, 2) == "10") RET = RET.REMOVE (0, 1); Return Ret;}

// Conversion Integer Private String Toint (String X) {INT LEN = X.LENGTH; String Ret, Temp; IF (LEN <= 4) Ret = Changeint (x); Else IF (LEN <= 8) {Ret = Changeint (X.Substring (0, LEN-4)) "10,000"; Temp = Changeint (X.Substring (LEN-4, 4)); if (Temp.indexof ("Thousand") == - 1 && Temp! = "") RET = "zero" Temp; Else Ret = Temp;} else {RET = Changeint (x.substring (0, len-8)) "100 million"; Temp = Changeint (x.substring LEN-8, 4)); IF (Temp.indexof ("Thousand") == - 1 && Temp! = "") RET = "Zero" Temp; Else Ret = Temp; RET = "Wan" Temp = Changeint (X.Substring (LEN-4, 4)); if (Temp.indexof ("Thousand") == - 1 && Temp! = "") RET = "Zero" Temp; Else Ret = Temp;} INT i; IF ((i = ret.indexof ("万"))! = - 1) Ret = RET.Remove (i 1, 1); while ((i = ret.indexof) Zero Zero "))! = - 1) RET = RET.Remove (I, 1); if (Ret [Ret.Length-1] == 'zero' && Ret.length> 1) RET = RET.REMOVE (RET .Length-1, 1); return return;} private string todaycimal (string x) {string Ret = ""; for (int i = 0; i

Public String NumTochn (String X) {if (x.length == 0) Return ""; string rett = ""; if (x [0] == '-') {RET = "negative"; x = x. REMOVE (0, 1);} if (x [0] .tostring () == ".") X = "0" x; if (x [x.length-1] .tostring () == ". ") X = x.Remove (xLength-1, 1); if (x.indexof (". ")> - 1) RET = Toint (x.substring (0, x.indexof (". ") )) "Point" Todecimal (x.indexof (") 1)); Else Ret = toint (x); return ret;}}} This is the test engineering Using system;

Namespace consoleapp {class mainclass {static void main (string [] args) {/ * system.console.writeline ("Hello, THE World!"); System.Console.writeline ("My Love!");

Classtest CT = new classtest (); system.console.writeline (ct.get_str ()); * / / * // Overload operator MyVector V1 = New MyVector (5, 12); MyVector V2 = New MyVector (4, 3); MyVector v3 = new myvector (); v3 = v1 v2; system.console.writeline ("{0} test", v3.length); * /

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

New Post(0)