-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnumber_reader.go
72 lines (66 loc) · 1.75 KB
/
number_reader.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package main
import (
"fmt"
)
func main() {
fmt.Print("Sonni kiriting: ")
var input string
fmt.Scanln(&input)
fmt.Println(reader(input))
}
func reader(son string) string {
uch_xonaliklar := []string{"", "ming ","million ", "milliard ", "trillion ", "kvatrillion ", "kvintillion ", "sekstillion ","septillion ", "oktillion ","nonillion ", "detsillion ","undetsillion ", "dodetsillion ","tredetsillion ","kvattuordetsillion "}
sonUzunligi := int(len(son))
for sonUzunligi%3!=0 {
son = "0"+son
sonUzunligi++
}
//fmt.Println(son)
for i:=0;i<sonUzunligi/3;i++{
beingRead := son[i*3:(i+1)*3]
littleReader(beingRead)
if beingRead !="000" {
fmt.Print(uch_xonaliklar[int(sonUzunligi/3)-i-1])
}
}
return ""
}
func littleReader(n string) string {
son_uzunligi := len(n)
for i,raqam := range n {
switch son_uzunligi-i {
case 1: birlik(string(raqam))
case 2: onlik(string(raqam))
case 3: birlik(string(raqam)); if string(raqam)!="0" {fmt.Print("yuz ")}
}
}
return ""
}
func birlik(raqam string) string {
switch string(raqam) {
case "1": fmt.Print("bir", " ")
case "2": fmt.Print("ikki", " ")
case "3": fmt.Print("uch", " ")
case "4": fmt.Print("to'rt", " ")
case "5": fmt.Print("besh", " ")
case "6": fmt.Print("olti", " ")
case "7": fmt.Print("yetti", " ")
case "8": fmt.Print("sakkiz", " ")
case "9": fmt.Print("to'qqiz", " ")
}
return ""
}
func onlik(raqam string) string {
switch string(raqam) {
case "1": fmt.Print("o'n", " ")
case "2": fmt.Print("yigirma", " ")
case "3": fmt.Print("o'ttiz", " ")
case "4": fmt.Print("qirq", " ")
case "5": fmt.Print("ellik", " ")
case "6": fmt.Print("oltmish", " ")
case "7": fmt.Print("yetmish", " ")
case "8": fmt.Print("sakson", " ")
case "9": fmt.Print("to'qson", " ")
}
return ""
}