Compare commits

...

3 Commits

Author SHA1 Message Date
990e803a14 save
All checks were successful
Test Go Action / use-go-action (push) Successful in 7s
2025-02-10 21:43:38 +03:00
17bd180803 actions 2024-12-21 13:14:52 +03:00
a63625798e actions 2024-12-21 13:14:07 +03:00
6 changed files with 82 additions and 22 deletions

BIN
cmd/a.out

Binary file not shown.

View File

@ -1,7 +1,11 @@
package main package main
import "fmt" import (
"fmt"
"gowinter/internal"
)
func main() { func main() {
fmt.Println("Welcome to rise field!!!") fmt.Println("Welcome to rise field!!")
internal.Run()
} }

View File

@ -1,19 +0,0 @@
// C++ Code to demonstrate getppid()
#include <iostream>
#include <unistd.h>
using namespace std;
// Driver Code
int main()
{
int pid;
pid = fork();
if (pid == 0)
{
cout << "\nParent Process id : "
<< getpid() << endl;
cout << "\nChild Process with parent id : "
<< getppid() << endl;
}
return 0;
}

2
go.mod
View File

@ -1,3 +1,3 @@
module gowinter module gowinter
go 1.23.3 go 1.20

16
internal/example.go Normal file
View File

@ -0,0 +1,16 @@
package internal
import (
"fmt"
"time"
)
func Add(a, b int) {
time.Sleep(time.Second)
fmt.Println("Sum =", a+b)
}
func Sub(a, b int) {
time.Sleep(time.Second)
fmt.Println("Sub =", a-b)
}

View File

@ -0,0 +1,59 @@
package internal
import "fmt"
var operators []string = []string{"+", "-", "*", "/"}
func Run() {
var x, y int
var operator string
fmt.Println("Введите первое число")
_, err := fmt.Scan(&x)
if err != nil {
fmt.Printf("Некорректное число.\n")
return
}
fmt.Println("Введите операцию (+,-,*,/)")
fmt.Scan(&operator)
if !isExistOperato(operator) {
fmt.Printf("Некоректная операция.\n")
return
}
fmt.Println("Введите второе число")
_, err = fmt.Scan(&y)
if err != nil {
fmt.Printf("Некорректное число.\n")
return
}
calculate(x, y, operator)
}
func isExistOperato(operatop string) bool {
for _, op := range operators {
if op == operatop {
return true
}
}
return false
}
func calculate(x, y int, oprator string) {
switch oprator {
case "+":
fmt.Printf("%d + %d = %d\n", x, y, x+y)
case "-":
fmt.Printf("%d - %d = %d\n", x, y, x-y)
case "*":
fmt.Printf("%d * %d = %d\n", x, y, x*y)
case "/":
if y == 0 {
fmt.Println("Ошибка: деление на 0 невозможно")
return
}
fmt.Printf("%d + %d = %f\n", x, y, float64(x)/float64(y))
}
}