main.go 392 B

123456789101112131415161718192021222324252627282930
  1. package main
  2. import (
  3. "bufio"
  4. "fmt"
  5. "os"
  6. )
  7. func main() {
  8. input := bufio.NewScanner(os.Stdin)
  9. var output string
  10. for input.Scan() {
  11. line := input.Text()
  12. output = replaceSpace(line)
  13. fmt.Println(output)
  14. }
  15. }
  16. func replaceSpace(s string) string {
  17. var last string
  18. for _, v := range s {
  19. if string(v) == " " {
  20. last += "%20"
  21. continue
  22. }
  23. last += string(v)
  24. }
  25. return last
  26. }