-
Notifications
You must be signed in to change notification settings - Fork 1
/
test111.go
46 lines (39 loc) · 872 Bytes
/
test111.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
// Sample code to perform I/O:
fmt.Scanf("%s", &myname) // Reading input from STDIN
fmt.Println("Hello", myname) // Writing output to STDOUT
// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail
*/
// Write your code here
package main
import (
"bufio"
"fmt"
"os"
"strconv"
"strings"
)
func main() {
var N int
fmt.Scanln(&N)
A := make([]int, N)
scanner := bufio.NewScanner(os.Stdin)
str := readString(scanner)
newstr := strings.Split(str, " ")
for i := 0; i < N; i++ {
s := newstr[i]
A[i], _ = strconv.Atoi(s)
}
fmt.Println("array:", A)
min := A[0]
for _, v := range A {
if v < min {
min = v
}
}
fmt.Println("Closest to Zero is:", min)
}
func readString(scanner *bufio.Scanner) string {
scanner.Scan()
return scanner.Text()
}