Skip to content

Latest commit

 

History

History
64 lines (47 loc) · 952 Bytes

1477.-pin-xie-zheng-que.md

File metadata and controls

64 lines (47 loc) · 952 Bytes

1477. 拼写正确

给定一个非负整数 NN,你的任务是计算 NN 的所有数字的总和,并以英语输出总和的每个数字。

输入格式

共一行,包含一个整数 NN。

输出格式

共一行,用英语输出总和的每个数字,单词之间用空格隔开。

数据范围

0≤N≤101000≤N≤10100

输入样例:

12345

输出样例:

one five
package main 

import (
    "fmt"
    "strconv"
    )
    
func main (){
    var n string
    fmt.Scanf("%s", &n)
    ans := 0 
    for _,v := range n {
        ans += (int(v - '0'))
    }
    commits := map[rune]string{
    '1': "one",
    '2': "two",
    '3' :"three",
    '4' :"four",
    '5' :"five",
    '6' :"six",
    '7' :"seven",
    '8' :"eight",
    '9' :"nine",
    '0' :"zero",
}
    // fmt.Println(ans)
    for _,v := range  strconv.Itoa(ans){
        fmt.Printf( "%s ", commits[v])
    }
}