A-M baby
This commit is contained in:
parent
764da6cbbb
commit
db842d013d
19005 changed files with 197040 additions and 7 deletions
36
Task/Integer-comparison/Go/integer-comparison.go
Normal file
36
Task/Integer-comparison/Go/integer-comparison.go
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"bufio"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue