Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import "fmt"
- func main() {
- var input, word, message string
- fmt.Scanln(&input)
- var c = 0
- var o = 0
- var n = 0
- for ; input != "End"; {
- var letter = input[0]
- if letter >= 'A' && letter <= 'Z' || letter >= 'a' && letter <= 'z' {
- if letter == 'c' && c == 0 {
- c++
- } else if letter == 'o' && o == 0 {
- o++
- } else if letter == 'n' && n == 0 {
- n++
- } else {
- word += string(letter)
- }
- if c == 1 && o == 1 && n == 1 {
- c--
- o--
- n--
- message += word + " "
- word = ""
- }
- }
- fmt.Scanln(&input)
- }
- fmt.Println(message)
- }
- ИЛИ:
- package main
- import (
- "fmt"
- "strings"
- )
- func main() {
- const alpha = "abcdefghijklmnopqrstuvwxyz"
- var input, word, message string
- var secretWord = "con"
- fmt.Scanln(&input)
- for ; input != "End"; {
- if strings.Contains(secretWord, input) {
- secretWord = strings.Replace(secretWord, input, "", 1)
- if secretWord == "" {
- secretWord = "con"
- message += word + " "
- word = ""
- }
- } else if strings.Contains(alpha, strings.ToLower(input)) {
- word += input
- }
- fmt.Scanln(&input)
- }
- fmt.Println(message)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement