0
|
1 |
#!/usr/bin/perl |
|
2 |
# |
|
3 |
# Szamolgato v1.0, 99/10/13 |
|
4 |
# (c)1999 peter 'grin' gervai |
|
5 |
# |
|
6 |
# kiirja egy szam erteket betukkel |
|
7 |
# |
|
8 |
|
|
9 |
$n=$ARGV[0] + 0; |
|
10 |
print "$n = ",&betukre($n),"\n"; |
|
11 |
#print &betukre($n),"\n"; |
|
12 |
|
|
13 |
|
|
14 |
sub betukre { |
|
15 |
my $n = shift; |
|
16 |
|
|
17 |
my @SZAM = ( 'nulla','egy','kett??','h??rom','n??gy','??t','hat','h??t','nyolc','kilenc' ); |
|
18 |
my @TIZES= ( '','tizen','huszon','harminc','negyven','??tven','hatvan','hetven','nyolcvan','kilencven' ); |
|
19 |
|
|
20 |
#my @HATVANY=( 'sz??z','ezer','milli??','milli??rd', 'billi??', 'billi??rd','trilli??', |
|
21 |
# 'trilli??rd', 'kvadrilli??', 'kvadrilli??rd', ); |
|
22 |
# my @EXP = ( 2, 3, 6, 9, 12, 15, 18 ); |
|
23 |
|
|
24 |
|
|
25 |
my @HATVANY = qw( sz??z ezer ); |
|
26 |
my @EXP = ( 2, 3 ); |
|
27 |
# \/ idaig tart a szamabrazolas :) |
|
28 |
my @hatvanyok1 = qw( milli billi trilli kvadrilli kvintilli szextilli |
|
29 |
szeptilli oktilli nonilli decilli undecilli bidecilli tridecilli kvadecilli kvintdecilli szexdecilli ); |
|
30 |
for my $i ( 1..16 ) { |
|
31 |
push @HATVANY, $hatvanyok1[$i-1] . '??'; |
|
32 |
push @EXP, $i*6; |
|
33 |
push @HATVANY, $hatvanyok1[$i-1] . '??rd'; |
|
34 |
push @EXP, $i*6+3; |
|
35 |
} |
|
36 |
|
|
37 |
push @HATVANY, 'googol'; |
|
38 |
push @EXP, 100; |
|
39 |
|
|
40 |
push @HATVANY, 'centilli??'; |
|
41 |
push @EXP, 600; |
|
42 |
|
|
43 |
# 1 googolplex = 10^googol = 10^(10^100) |
|
44 |
|
|
45 |
my $out = ""; |
|
46 |
|
|
47 |
for( my $hatv=$#HATVANY; $hatv>=0; $hatv-- ) { |
|
48 |
# 10^$hatv az alap |
|
49 |
my $hatv_num = $EXP[$hatv]; |
|
50 |
my $alap = "1e$hatv_num" + 0; |
|
51 |
if( $n>=$alap ) { |
|
52 |
my $resz = int($n / $alap); |
|
53 |
$out .= '-' if $out ne ''; |
|
54 |
$out = $out . &betukre($resz) . $HATVANY[$hatv]; |
|
55 |
$n -= $resz * $alap; |
|
56 |
} |
|
57 |
} |
|
58 |
|
|
59 |
if( $n > 99 ) { |
|
60 |
$out .= '-' if $out ne ''; |
|
61 |
$out .= "SOK"; |
|
62 |
} elsif( $n > 9 ) { |
|
63 |
$out .= '-' if $out ne ''; |
|
64 |
if( $n==10 ) { |
|
65 |
$out .= 't??z'; |
|
66 |
} elsif( $n==20 ) { |
|
67 |
$out .= 'h??sz'; |
|
68 |
} else { |
|
69 |
my $tizen = int( $n / 10); |
|
70 |
$out .= $TIZES[$tizen] unless $tizen==0; |
|
71 |
my $egyen = $n - ($tizen * 10); |
|
72 |
$out .= $SZAM[$egyen] unless $egyen==0; |
|
73 |
} |
|
74 |
} elsif( $n > 0 ) { |
|
75 |
$out .= '-' if $out ne ''; |
|
76 |
$out .= $SZAM[$n]; |
|
77 |
} |
|
78 |
|
|
79 |
return $out; |
|
80 |
} |
|
81 |
|