Advertisement
Spocoman

02. Password

Sep 21st, 2024
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.65 KB | None | 0 0
  1. package main
  2.  
  3. import "fmt"
  4.  
  5. func main() {
  6.     var username, password string
  7.     fmt.Scanln(&username)
  8.     fmt.Scanln(&password)
  9.    
  10.     var input = ""
  11.  
  12.     for ;; {
  13.         fmt.Scanln(&input)
  14.         if input == password {
  15.             fmt.Println("Welcome " + username + "!")
  16.             break
  17.         }
  18.     }
  19. }
  20.  
  21. ИЛИ:
  22.  
  23. package main
  24.  
  25. import "fmt"
  26.  
  27. func main() {
  28.     var username, password string
  29.     fmt.Scanln(&username)
  30.     fmt.Scanln(&password)
  31.    
  32.     var input string
  33.     fmt.Scanln(&input)
  34.  
  35.     for i := 0 ; input != password; i++ {
  36.         fmt.Scanln(&input)
  37.     }
  38.    
  39.     fmt.Println("Welcome " + username + "!")
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement