"Go Language Programming" Learning (ii)

Source: Internet
Author: User

Basis

One, hello

  1 package Main                                                                                   2                                                                         3 Import (4 "FMT"                                                                          5 "OS"                                                                                 6 "strings" 7)                                                                                   8 9 Func Main () {ten Who: = "W Orld "one-to-one" if Len (OS.                                               Args) > 1 {         who = strings. Join (OS.                                                                            Args[1:], "") 13} FMT.              Println ("Hello", WHO) 15}

  

It seems that there is nothing to explain, the direct run on the line.

Two, bigdigits

  1Package Main 2                                                                                                     3Import (4     "FMT"                                                                                           5     "Log"                                                                                           6     "OS"                                                                                            7     "Path/filepath"                                                                                 8 )                                                                                                   9                                                                                                    TenFunc Main () { One     ifLen (OS. Args) = =1 {                                                                          AFmt. Println ("Usage:%s <whole-number>\n", filepath. Base (OS. args[0]))                        -Os. Exit (1)                                                                                  -     }                                                                                               theStringofdigits: = os. args[1]                                                                    -      forRow: = Range bigdigits[0] {                                                                 -Line: =""                                                                                  -          forColumn: =Range Stringofdigits { +Digit: = Stringofdigits[column]-'0'                                                   -             if 0<= Digit && Digit <=9 {                                                           +Line + = Bigdigits[digit][row] +" "                                                 A}Else {                                                                                atLog. Fatal ("invalid who number")                                                     -             }                                                                                       -         }                                                                                           -FMT. Println (line) -     }                                                                                               - }                                                                                                   in                                                                                                     - varBigdigits = []string{                                                                         to{" the",                                                                                     +         "0 0",                                                                                  -         "0 0",                                                                                  the         "0 0",                                                                                  *         "0 0",                                                                                  $         "0 0",                                                               Panax Notoginseng         " the"},                                                                                 -{"1"," One","1","1","1","1","111"},                                              the{"222","2 2","2","2","2","2","22222"},                                +{"333","3 3","3"," -","3","3 3","333"},                                A{"4"," -","4 4","4 4","444444","4",                                    the         "4"},                                                                                  +{"55555","5","5","555","5","5 5","555"},                                -{"666","6","6","6666","6 6","6 6","666"},                                ${"77777","7","7","7","7","7","7"},                                ${"888","8 8","8 8","888","8 8","8 8","888"},                                -{"9999","9 9","9 9","9999","9","9","9"},                                - }                                                                                                 ~

This piece of code: There seems to be nothing to say. Well, use range to get the offset of the relative ' 0 ' of each parameter number, and then stitch together the string representation of the corresponding line of each number. Sort of like a pixel puzzle.

"Go Language Programming" Learning (ii)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.