VariableAmountOfArgs

This commit is contained in:
Alexander Pivkin
2025-08-26 19:45:51 +03:00
parent 00347310c1
commit f88a392425
14 changed files with 131 additions and 3 deletions
+6
View File
@@ -0,0 +1,6 @@
1
2
3
4
5
6
+3
View File
@@ -0,0 +1,3 @@
module main
go 1.24.5
BIN
View File
Binary file not shown.
+22
View File
@@ -0,0 +1,22 @@
package main
import (
"fmt"
"main/sub"
"os"
)
func jp (mylist ...int) {
for _,i := range mylist {
fmt.Print(i," ")
}
}
func main() {
args := os.Args[1]
res := sub.Kek(args)
fmt.Println(res)
jp(1,2,3,4)
}
+20
View File
@@ -0,0 +1,20 @@
package sub
import (
"bufio"
"os"
"strconv"
)
func Kek(fileName string) []int {
var seg []int
counter := 0
file,_ := os.Open(fileName)
scanner := bufio.NewScanner(file)
for scanner.Scan() {
mid,_ := strconv.ParseInt(scanner.Text(),0,0)
seg = append(seg,int(mid))
counter++
}
return seg
}