Diary/2009-6-19
安易に単純に
漢字表記の場合,最大12桁ぐらいとして,4桁毎に1つのブロックと分けて考えればいいだろうな。ブロックは下位より「"","万","億"」がつくものとして,さらに「"一","十","百","千"」の1桁毎に分解する。えー,各桁で「0」の値は表現されない。さらに「"一"」の位で「1」の値は表現されるが「"十","百","千"」では「"一十","一百","一千"」とはあまり眼にしない。
my $value = 14193; #値を入れる
my $buf = ""; my (@t0)=("","一","二","三","四","五","六","七","八","九"); my (@t1)=("","","二","三","四","五","六","七","八","九"); my (@t2)=("","万","億","m3","m4","m5","m6","m7","m8","m9"); my ($w0,$w1,$w2,$w3,$w4)=(0,0,0,0,0) ; if ($value == 0 ) { $buf = "零"; } while ( $value ){ $buf = "$t2[$w0]" . $buf; $w4 = $value % 10000; $w1 = $w4 % 10; $w4 = int ($w4 / 10); $w2 = $w4 % 10; $w4 = int ($w4 / 10); $w3 = $w4 % 10; $w4 = int ($w4 / 10); $value = int ($value / 10000); $buf = "$t0[$w1]".$buf; if ($w2>0) { $buf = "$t1[$w2]十".$buf; } if ($w3>0) { $buf = "$t1[$w3]百".$buf; } if ($w4>0) { $buf = "$t1[$w4]千".$buf; } $w0++; }
で,まあヨシとするか。
☆
Today: 1 / Yesterday: 0