0
1
12
123
1234
12345
123456
1234567
12345678
123456789
1234567890
1
10
100
1000
10000
100000
1000000
10000000
100000000
1000000000
处理后:
zero
one
twelve
one hundred and twenty-three
one thousand,two hundred and thirty-four
twelve thousand,three hundred and forty-five
one hundred and twenty-three thousand,four hundred and fifty-six
one million,two hundred and thirty-four thousand,five hundred and sixty-seven
twelve million,three hundred and forty-five thousand,six hundred and seventy-eight
one hundred and twenty-three million,four hundred and fifty-six thousand,seven hundred and eighty-nine
one billion,two hundred and thirty-four million,five hundred and sixty-seven thousand,eight hundred and ninety
one
ten
one hundred
one thousand
ten thousand
one hundred thousand
one million
ten million
one hundred million
one billion
点击(此处)折叠或打开
-
#!/bin/awk -f
-
-
BEGIN {
-
FS=""
-
a[0]="zero"
-
a[1]="one"
-
a[2]="two"
-
a[3]="three"
-
a[4]="four"
-
a[5]="five"
-
a[6]="six"
-
a[7]="seven"
-
a[8]="eight"
-
a[9]="nine"
-
a[10]="ten"
-
a[11]="eleven"
-
a[12]="twelve"
-
a[13]="thirteen"
-
a[14]="fourteen"
-
a[15]="fifteen"
-
a[16]="sixteen"
-
a[17]="seventeen"
-
a[18]="eighteen"
-
a[19]="nineteen"
-
a[20]="twenty"
-
a[30]="thirty"
-
a[40]="forty"
-
a[50]="fifty"
-
a[60]="sixty"
-
a[70]="seventy"
-
a[80]="eighty"
-
a[90]="ninety"
-
}
-
-
{
-
for (i=1;i<=NF;i++) {
-
t=NF-i+1
-
k=0
-
if (!$i&&i>1) continue
-
if (!(t%3)) {
-
printf a[$i]" hundred"
-
if (!$(i+1)) {
-
if ($(i+2)) printf " and "a[$(i+2)]
-
i+=2
-
} else printf " and "
-
} else if (t%3==2) {
-
if ($i=="1") {
-
printf a[$i$(i+1)]
-
} else {
-
if ($(i+1)) printf a[$i*10]"-"a[$(i+1)];else printf a[$i*10]
-
}
-
i++
-
} else printf a[$i]
-
t=NF-i+1
-
if (t==4) printf " thousand"
-
if (t==7) printf " million"
-
if (t==10) printf " billion"
-
if (t%3==1) {
-
for (j=i+1;j<=NF;j++) if ($j) k=1
-
if (k) printf ","
-
}
-
}
-
print ""
- }