Just another update
This commit is contained in:
parent
a25938f123
commit
00a190b0a6
6591 changed files with 94363 additions and 23227 deletions
|
|
@ -1,36 +1,24 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"bufio"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"fmt"
|
||||
"log"
|
||||
)
|
||||
|
||||
func main() {
|
||||
in := bufio.NewReader(os.Stdin)
|
||||
getInt := func() int {
|
||||
fmt.Print("Integer: ")
|
||||
s, err := in.ReadString('\n')
|
||||
if err != nil {
|
||||
fmt.Println("\nComputer says input error")
|
||||
os.Exit(0)
|
||||
}
|
||||
i, err := strconv.Atoi(strings.TrimSpace(s))
|
||||
if err != nil {
|
||||
fmt.Println("Not an integer")
|
||||
os.Exit(0)
|
||||
}
|
||||
return i
|
||||
}
|
||||
|
||||
n1 := getInt()
|
||||
n2 := getInt()
|
||||
|
||||
switch {
|
||||
case n1 < n2: fmt.Println(n1, "less than", n2)
|
||||
case n1 == n2: fmt.Println(n1, "equal to", n2)
|
||||
case n1 > n2: fmt.Println(n1, "greater than", n2)
|
||||
}
|
||||
var n1, n2 int
|
||||
if _, err := fmt.Scan(&n1); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
if _, err := fmt.Scan(&n2); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
switch {
|
||||
case n1 < n2:
|
||||
fmt.Println(n1, "less than", n2)
|
||||
case n1 == n2:
|
||||
fmt.Println(n1, "equal to", n2)
|
||||
case n1 > n2:
|
||||
fmt.Println(n1, "greater than", n2)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue