12345678910111213141516171819202122232425262728293031 |
- package main
- import (
- "bufio"
- "fmt"
- "os"
- "strconv"
- "strings"
- )
- func main() {
- input := bufio.NewScanner(os.Stdin)
- var output string
- for input.Scan() {
- line := input.Text()
- values := strings.Split(line, " ")
- num, _ := strconv.Atoi(values[1])
- output = reverseLeftWords(values[0], num)
- fmt.Println(output)
- }
- }
- func reverseLeftWords(s string, n int) string {
- if len(s) <= n {
- return s
- }
- var prefix = s[0:n]
- return s[n:] + prefix
- }
|