add: numbers and strings exercises
This commit is contained in:
@ -0,0 +1,35 @@
|
||||
// For more tutorials: https://blog.learngoprogramming.com
|
||||
//
|
||||
// Copyright © 2018 Inanc Gumus
|
||||
// Learn Go Programming Course
|
||||
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||||
//
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// EXERCISE: Improved Banger
|
||||
//
|
||||
// Change the Banger program the work with Unicode
|
||||
// characters.
|
||||
//
|
||||
// INPUT
|
||||
// "İNANÇ"
|
||||
//
|
||||
// EXPECTED OUTPUT
|
||||
// İNANÇ!!!!!
|
||||
// ---------------------------------------------------------
|
||||
|
||||
func main() {
|
||||
msg := os.Args[1]
|
||||
|
||||
s := msg + strings.Repeat("!", len(msg))
|
||||
|
||||
fmt.Println(s)
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
// For more tutorials: https://blog.learngoprogramming.com
|
||||
//
|
||||
// Copyright © 2018 Inanc Gumus
|
||||
// Learn Go Programming Course
|
||||
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||||
//
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"unicode/utf8"
|
||||
)
|
||||
|
||||
func main() {
|
||||
msg := os.Args[1]
|
||||
l := utf8.RuneCountInString(msg)
|
||||
|
||||
s := msg + strings.Repeat("!", l)
|
||||
|
||||
fmt.Println(s)
|
||||
}
|
Reference in New Issue
Block a user