Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import "fmt"
- func main() {
- var book, input string
- fmt.Scanln(&book)
- for counter := 0; ; counter++ {
- fmt.Scanln(&input)
- if input == book {
- fmt.Printf("You checked %d books and found it.\n", counter)
- break
- }
- if input == "NoMoreBooks" {
- fmt.Printf("The book you search is not here!\nYou checked %d books.\n", counter)
- break
- }
- }
- }
- ИЛИ:
- package main
- import "fmt"
- func main() {
- var book, input string
- fmt.Scanln(&book)
- var counter = -1
- for ; input != book && input != "NoMoreBooks"; {
- fmt.Scanln(&input)
- counter++
- }
- if input == book {
- fmt.Printf("You checked %d books and found it.\n", counter)
- } else {
- fmt.Printf("The book you search is not here!\nYou checked %d books.\n", counter)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement