The simplest algorithm for converting Arabic digital to Chinese capital

xiaoxiao2021-03-06  87

Subject: [Large scattered points] consciously find the simplest algorithm of a convert Arabic numerals to the Chinese capital: fanz2000 (et) credit value: 99 belongs forum: .NET technology C # questions Points: 100 Replies: 46 Time: 2004-8-16 14:46:32 The code is as follows:

/ / Add to the defined part of the class

Private static string [] cstr = {"zero", "", "", "叁", "", "", "柒", "柒", "捌", "玖"}

Private static string [] wstr = {"", "" "," "," 仟 "," 万 "," "," 佰 "," "," hundreds "," pick ", "", ""};

// The number must be within 12-bit integers

// Call method such as: label1.text = Convertint ("Digital String");

Public String Convertint (String STR)

{

INT LEN = str.length;

INT I;

String Tmpstr, RSTR;

RSTR = ""

For (i = 1; i <= le; i )

{

Tmpstr = Str.Substring (LEN-I, 1);

Rstr = string.concat (cstr [int32.parse (tmpstr)] WSTR [I], RSTR);

}

Rstr = rstr.replace ("Picking", "Pick");

rstr = rstr.replace ("Zero Pick", "Zero");

rstr = rstr.replace ("Zero", "zero");

rstr = rstr.replace ("zero", "zero");

RSTR = RSTR.Replace ("万", "10,000");

For (i = 1; i <= 6; i )

Rstr = rstr.replace ("zero zero", "zero");

Rstr = rstr.replace ("万", "zero");

Rstr = rstr.replace ("iod of" "," hundreds ");

Rstr = rstr.replace ("zero zero", "zero");

RSTR = "round";

Return RSTR;

}

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

New Post(0)