Go language output example of a number

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed. Copyright leaked 2010-12 Qtrac Ltd.
//
This program or package and any associated files is licensed under the
Apache License, Version 2.0 (the "License"); These files
Except in compliance with the License. You can get a copy of the License
at:http://www.apache.org/licenses/license-2.0.
//
Unless required by applicable law or agreed to writing, software
Distributed under the License is distributed on a "as is" BASIS,
Without warranties or CONDITIONS of any KIND, either express or implied.
See the License for the specific language governing permissions and
Limitations under the license.//   uses the repeat function in the strings package
Package Main
Import (
"FMT"
"Log"
"OS"
"Path/filepath"
"Strings"
)
Func Main () {
If Len (OS. Args) = = 1 {
Fmt. Printf ("Usage:%s <whole-number>\n", filepath. Base (OS. Args[0]))
Os. Exit (1)
}
Stringofdigits: = os. ARGS[1]
Add ******  to use the repeat function in the strings package
Fmt. PRINTLN (Strings. Repeat ("*", Len (stringofdigits) *6))
/* for I: = 0; I < Len (stringofdigits) *6; i++ {
Fmt. Print ("*")
}
Fmt. Print ("\ n") */
For row: = Range Bigdigits[0] {
Line: = ""
For _, Digit: = Range Stringofdigits {
Digit-= ' 0 '
If 0 <= digit && digit <= 9 {
Line + = Bigdigits[digit][row] + "  "
} else {
Log. Fatal ("Invalid whole number")
}
}
Fmt. Println (line)
}
For I: = 0; I < Len (stringofdigits) *6; i++ {
Fmt. Print ("*")
}
Fmt. Print ("\ n")
}
var bigdigits = [][]string{
{"  to",
"0   0",
"0     0",
"0     0",
"0     0",
"0   0",
"  to"},
{"1", "11", "1", "1", "1", "1", "111"},
{"222", "2   2", "   2", "  2  ", "2   ", "2    ", "22222"},
{"333", "3   3", "    3", "All"  , "    3", "3   3", "333"},
{"   4  ", "4", "  4  ", "4  4  ", "444444", "   4  ",
"   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"},
}


Test.ext 123

******************
1 222 333
11 2 2) 3 3
1 2 3
1 2 33
1 2 3
1 2 3 3
111 22222 333
******************



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.