minorr changes
This commit is contained in:
commit
87d180eab1
98 changed files with 1856 additions and 0 deletions
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
.vscode
|
||||
.env
|
||||
.idea
|
||||
go_build_my_app
|
||||
1
README.md
Normal file
1
README.md
Normal file
|
|
@ -0,0 +1 @@
|
|||
)(*&^%$%^&*()(*&^%$%^&*()(*&^%$%^&*()(*&^%$#$%^&*))))
|
||||
1
asm/.gitignore
vendored
Normal file
1
asm/.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
l1.o
|
||||
1
asm/README.md
Normal file
1
asm/README.md
Normal file
|
|
@ -0,0 +1 @@
|
|||
Ой нееее зря я сюда полез
|
||||
17
asm/l1.asm
Normal file
17
asm/l1.asm
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
section .data
|
||||
msg db 'Hello, World!'
|
||||
len equ $ - msg
|
||||
|
||||
section .text
|
||||
global _start
|
||||
|
||||
_start:
|
||||
mov rax, 1
|
||||
mov rdi, 1
|
||||
mov rsi, msg
|
||||
mov rdx, len
|
||||
syscall
|
||||
|
||||
mov rax, 60
|
||||
xor rdi, rdi
|
||||
syscall
|
||||
BIN
asm/output/l1
Executable file
BIN
asm/output/l1
Executable file
Binary file not shown.
2
c++/.gitignore
vendored
Normal file
2
c++/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
.vscode
|
||||
.env
|
||||
5
c++/l1.cpp
Normal file
5
c++/l1.cpp
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
#include <iostream>
|
||||
int main() {
|
||||
std::cout << "hello" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
11
c++/l2.cpp
Normal file
11
c++/l2.cpp
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
#include <iostream>
|
||||
int main() {
|
||||
int x;
|
||||
std::cout << "Число " << std::endl;
|
||||
std::cin >> x;
|
||||
int x2;
|
||||
std::cout << "Второе число " << std::endl;
|
||||
std::cin >> x2;
|
||||
int sum = x+x2;
|
||||
std::cout << x << "+" << x2 << "=" << sum << std::endl;
|
||||
}
|
||||
12
c++/l3.cpp
Normal file
12
c++/l3.cpp
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#include <iostream>
|
||||
int main() {
|
||||
int x;
|
||||
std::cout << "Число" << std::endl;
|
||||
std::cin >> x;
|
||||
if(x > 10) {
|
||||
std::cout << "Число больше 10" << std::endl;
|
||||
}
|
||||
else {
|
||||
std::cout << "Число меньше 10" << std::endl;
|
||||
}
|
||||
}
|
||||
8
c++/l4.cpp
Normal file
8
c++/l4.cpp
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
#include <iostream>
|
||||
#include <string>
|
||||
int main() {
|
||||
std::string x;
|
||||
std::cout << "Кто сергей" << std::endl;
|
||||
std::getline(std::cin, x);
|
||||
std::cout << "сергей " << x << std::endl;
|
||||
}
|
||||
55
c++/l5.cpp
Normal file
55
c++/l5.cpp
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
int polz(void) {
|
||||
while(1) {
|
||||
std::string pol;
|
||||
std::cout << "Знак" << std::endl;
|
||||
std::cin >> pol;
|
||||
double x1;
|
||||
std::cout << "Первое число" << std::endl;
|
||||
std::cin >> x1;
|
||||
double x2;
|
||||
std::cout << "Второе число" << std::endl;
|
||||
std::cin >> x2;
|
||||
if(pol == "+") {
|
||||
std::cout << x1 << pol << x2 << "=" << x1+x2 << std::endl;
|
||||
}
|
||||
else if(pol == "-") {
|
||||
std::cout << x1 << pol << x2 << "=" << x1-x2 << std::endl;
|
||||
}
|
||||
else if(pol == "exit") {
|
||||
break;
|
||||
}
|
||||
else if(pol == "*") {
|
||||
std::cout << x1 << pol << x2 << "=" << x1*x2 << std::endl;
|
||||
}
|
||||
else if(pol == "/") {
|
||||
std::cout << x1 << pol << x2 << "=" << x1/x2 << std::endl;
|
||||
}
|
||||
else {
|
||||
std::cout << "Неверный знак" << std::endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int main() {
|
||||
while(1) {
|
||||
std::cout << "1. Начать\n2. Закончить" << std::endl;
|
||||
int pol1;
|
||||
std::cout << "Введите число" << std::endl;
|
||||
std::cin >> pol1;
|
||||
if(pol1 == 1) {
|
||||
polz();
|
||||
}
|
||||
else if(pol1 == 2) {
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
std::cout << "Введите верное число" << std::endl;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
43
c++/l6.cpp
Normal file
43
c++/l6.cpp
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
#include <iostream>
|
||||
#include <random>
|
||||
#include <string>
|
||||
|
||||
int all() {
|
||||
std::random_device rd;
|
||||
std::mt19937 gen(rd());
|
||||
std::uniform_int_distribution<int> distrib(1, 100);
|
||||
int i = 0;
|
||||
while(i <= 3) {
|
||||
int x1 = distrib(gen);
|
||||
int x2 = distrib(gen);
|
||||
int x3 = x1+x2;
|
||||
int pol;
|
||||
std::cout << x1 << "+" << x2 << "=?" << std::endl;
|
||||
std::cin >> pol;
|
||||
if(pol == x3) {
|
||||
std::cout << "Верно!" << std::endl;
|
||||
std::cout << x1 << "+" << x2 << "=" << x3 << std::endl;
|
||||
}
|
||||
else {
|
||||
std::cout << "Не верно!" << std::endl;
|
||||
std::cout << x1 << "+" << x2 << "=" << x3 << std::endl;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int main() {
|
||||
while(1) {
|
||||
std::string polz;
|
||||
std::cout << "1. Начать\n2. Закончить" << std::endl;
|
||||
std::cin >> polz;
|
||||
if(polz == "1") {
|
||||
all();
|
||||
}
|
||||
else if(polz == "2") {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
BIN
c++/output/l1
Executable file
BIN
c++/output/l1
Executable file
Binary file not shown.
BIN
c++/output/l2
Executable file
BIN
c++/output/l2
Executable file
Binary file not shown.
BIN
c++/output/l3
Executable file
BIN
c++/output/l3
Executable file
Binary file not shown.
BIN
c++/output/l4
Executable file
BIN
c++/output/l4
Executable file
Binary file not shown.
BIN
c++/output/l5
Executable file
BIN
c++/output/l5
Executable file
Binary file not shown.
BIN
c++/output/l6
Executable file
BIN
c++/output/l6
Executable file
Binary file not shown.
3
c/.gitignore
vendored
Normal file
3
c/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
.vscode
|
||||
.env
|
||||
output
|
||||
5
c/l1.c
Normal file
5
c/l1.c
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
#include <stdio.h>
|
||||
int main() {
|
||||
printf("hello\n");
|
||||
return 0;
|
||||
}
|
||||
16
c/l10.c
Normal file
16
c/l10.c
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int main() {
|
||||
char str[100];
|
||||
printf("Enter phrase ");
|
||||
scanf("%s", str);
|
||||
int len = strlen(str);
|
||||
if(len > 50) {
|
||||
printf("too long");
|
||||
return 0;
|
||||
}
|
||||
for(int i = 0; i < len; i++) {
|
||||
printf("%c\n", str[i]);
|
||||
}
|
||||
}
|
||||
51
c/l11.c
Normal file
51
c/l11.c
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main() {
|
||||
int x = 0;
|
||||
char str[100];
|
||||
printf("Enter word ");
|
||||
scanf("%s", str);
|
||||
int len = strlen(str);
|
||||
for(int i = 0; i < len; i++) {
|
||||
if(str[i] == 'a') {
|
||||
x++;
|
||||
}
|
||||
else if(str[i] == 'e') {
|
||||
x++;
|
||||
}
|
||||
else if(str[i] == 'i') {
|
||||
x++;
|
||||
}
|
||||
else if(str[i] == 'o') {
|
||||
x++;
|
||||
}
|
||||
else if(str[i] == 'u') {
|
||||
x++;
|
||||
}
|
||||
else if(str[i] == 'y') {
|
||||
x++;
|
||||
}
|
||||
else if(str[i] == 'A') {
|
||||
x++;
|
||||
}
|
||||
else if(str[i] == 'E') {
|
||||
x++;
|
||||
}
|
||||
else if(str[i] == 'I') {
|
||||
x++;
|
||||
}
|
||||
else if(str[i] == 'O') {
|
||||
x++;
|
||||
}
|
||||
else if(str[i] == 'U') {
|
||||
x++;
|
||||
}
|
||||
else if(str[i] == 'Y') {
|
||||
x++;
|
||||
}
|
||||
}
|
||||
printf("Vowels: %d\n", x);
|
||||
sleep(2);
|
||||
}
|
||||
11
c/l12.c
Normal file
11
c/l12.c
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main() {
|
||||
char x[100] = "False";
|
||||
while(1) {
|
||||
printf("%s\n", x);
|
||||
if(x == "True") {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
26
c/l13.c
Normal file
26
c/l13.c
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
int main() {
|
||||
char pol[100];
|
||||
printf("Enter word ");
|
||||
scanf("%s", pol);
|
||||
for(int i = 0; pol[i]; i++) {
|
||||
pol[i] = tolower(pol[i]);
|
||||
}
|
||||
char x[100];
|
||||
strcpy(x, pol);
|
||||
int len = strlen(x);
|
||||
for(int i = 0; i < len / 2; i++) {
|
||||
char temp = x[i];
|
||||
x[i] = x[len - 1 - i];
|
||||
x[len - 1 - i] = temp;
|
||||
}
|
||||
if(strcmp(pol, x) == 0) {
|
||||
printf("equal\n");
|
||||
}
|
||||
else {
|
||||
printf("not equal\n");
|
||||
}
|
||||
}
|
||||
19
c/l14.c
Normal file
19
c/l14.c
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main() {
|
||||
int num[5];
|
||||
for (int i = 0; i < 5; i++) {
|
||||
printf("Enter number ");
|
||||
scanf("%d", &num[i]);
|
||||
}
|
||||
|
||||
int max = num[0];
|
||||
for (int i = 1; i < 5; i++) {
|
||||
if (num[i] > max) {
|
||||
max = num[i];
|
||||
}
|
||||
}
|
||||
|
||||
printf("Maximum number: %d\n", max);
|
||||
return 0;
|
||||
}
|
||||
7
c/l2.c
Normal file
7
c/l2.c
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
#include <stdio.h>
|
||||
int main() {
|
||||
char x[100];
|
||||
printf("Who Sergay ");
|
||||
scanf("%99s", x);
|
||||
printf("Sergay: %s\n", x);
|
||||
}
|
||||
11
c/l3.c
Normal file
11
c/l3.c
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
#include <stdio.h>
|
||||
int main() {
|
||||
int pol1;
|
||||
printf("First number ");
|
||||
scanf("%d", &pol1);
|
||||
int pol2;
|
||||
printf("Second number ");
|
||||
scanf("%d", &pol2);
|
||||
int x = pol1*pol2;
|
||||
printf("Square: %d\n", x);
|
||||
}
|
||||
33
c/l4.c
Normal file
33
c/l4.c
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
int main() {
|
||||
srand(time(NULL));
|
||||
int x = rand() % 11;
|
||||
int s = 0;
|
||||
while(1) {
|
||||
int pol;
|
||||
printf("Number ");
|
||||
scanf("%d", &pol);
|
||||
if(pol == x) {
|
||||
printf("the number is guessed\n");
|
||||
break;
|
||||
}
|
||||
else {
|
||||
printf("the number is not guessed\n");
|
||||
if(pol > x) {
|
||||
printf("less\n");
|
||||
}
|
||||
else {
|
||||
printf("more\n");
|
||||
}
|
||||
s++;
|
||||
if(s == 3) {
|
||||
printf("Game over\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
28
c/l5.c
Normal file
28
c/l5.c
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main() {
|
||||
int pol;
|
||||
printf("Enter number ");
|
||||
scanf("%d", &pol);
|
||||
if(pol > 9) {
|
||||
printf("Error: number must be from 1 to 9\n");
|
||||
return 0;
|
||||
}
|
||||
else if(pol < 1) {
|
||||
printf("Error: number must be from 1 to 9\n");
|
||||
return 0;
|
||||
}
|
||||
int x = 1;
|
||||
int s = 0;
|
||||
while(1) {
|
||||
printf("%d * %d = %d\n", pol, x, pol*x);
|
||||
x++;
|
||||
s++;
|
||||
if(s < 10) {
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
12
c/l6.c
Normal file
12
c/l6.c
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main() {
|
||||
int pol;
|
||||
printf("Enter 3 number ");
|
||||
scanf("%d", &pol);
|
||||
int x1 = pol % 10;
|
||||
int x2 = (pol / 10) % 10;
|
||||
int x3 = ((pol / 10) / 10) % 10;
|
||||
int sum = x1+x2+x3;
|
||||
printf("%d\n", sum);
|
||||
}
|
||||
21
c/l7.c
Normal file
21
c/l7.c
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int main() {
|
||||
int pol;
|
||||
printf("Enter number: ");
|
||||
if (scanf("%d", &pol) != 1);
|
||||
|
||||
char st[100] = "";
|
||||
int x = 0;
|
||||
|
||||
if (pol >= 100) pol = 99;
|
||||
|
||||
while(x < pol) {
|
||||
int len = strlen(st);
|
||||
st[len] = '*';
|
||||
st[len + 1] = '\0';
|
||||
x++;
|
||||
printf("%s\n", st);
|
||||
}
|
||||
}
|
||||
21
c/l8.c
Normal file
21
c/l8.c
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int main() {
|
||||
char pol[100];
|
||||
printf("Enter word ");
|
||||
scanf("%s", pol);
|
||||
char x[100] = "hello";
|
||||
x[0] = 'H';
|
||||
x[1] = 'i';
|
||||
strcpy(&x[2], &x[5]);
|
||||
strcat(x, "!");
|
||||
if(strcmp(x, pol) == 0) {
|
||||
printf("equal\n");
|
||||
}
|
||||
else {
|
||||
printf("not equal\n");
|
||||
}
|
||||
int len = strlen(x), len2 = strlen(pol);
|
||||
printf("Symbol: %d\n%s\nSymbol your word: %d", len, x, len2);
|
||||
}
|
||||
16
c/l9.c
Normal file
16
c/l9.c
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int main() {
|
||||
char pol[100];
|
||||
printf("Enter word ");
|
||||
scanf("%s", pol);
|
||||
int len = strlen(pol);
|
||||
for(int i = 0; i < len / 2; i++) {
|
||||
char temp = pol[i];
|
||||
pol[i] = pol[len - 1 - i];
|
||||
pol[len - 1 - i] = temp;
|
||||
}
|
||||
printf("%s\n", pol);
|
||||
return 0;
|
||||
}
|
||||
28
git.sh
Normal file
28
git.sh
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
#!/bin/bash
|
||||
|
||||
echo "name for commit: "
|
||||
read com
|
||||
git add .
|
||||
git commit -m "$com"
|
||||
declare -A remotes=(
|
||||
["github"]="git@github.com:hhu67/my.git"
|
||||
["forgejo"]="forgejo@git.vlv-s.site:hhu67/my.git"
|
||||
["berg"]="ssh://git@codeberg.org/hhu67/my.git"
|
||||
["gitea.org"]="git@gitea.com:hhu67/my.git"
|
||||
)
|
||||
manage_remote() {
|
||||
local name=$1
|
||||
local url=$2
|
||||
|
||||
if git remote | grep -q "^${name}$"; then
|
||||
echo "Remote '$name' уже существует, пропускаю добавление."
|
||||
else
|
||||
echo "Добавляю remote: $name"
|
||||
git remote add "$name" "$url"
|
||||
fi
|
||||
}
|
||||
for name in "${!remotes[@]}"; do
|
||||
manage_remote "$name" "${remotes[$name]}"
|
||||
echo "Пушу в $name..."
|
||||
git push "$name" main
|
||||
done
|
||||
4
go/.gitignore
vendored
Normal file
4
go/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
.vscode
|
||||
.env
|
||||
.*.go.swp
|
||||
*.so
|
||||
38
go/README.md
Normal file
38
go/README.md
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
strings:
|
||||
.ToLower(x) - для одного нижнего регистра
|
||||
.ToUpper(x) - для одного высокого регистра
|
||||
.HasSuffix(x, "aaa") - для проверки оканчивается ли x на ааа(true/false)
|
||||
.HasPrefix(x, "aaa") - для проверки начинается ли x на aaa(true/false)
|
||||
.Contains(x, "aaa") - для проверки существует ли вообще aaa в x(true/false)
|
||||
.ContainsAny(x, "abc") - для проверки есть ли в x буквы a b c(true/false)
|
||||
.Count(x, "aaa") - для продсчета сколько в x aaa
|
||||
.EqualFold(x, x2) - сравнивает переменные без учета их регистра
|
||||
slices:
|
||||
x := []int{} - создание среза
|
||||
x := make([]int, a, b) - создание среза с параметром, a - длинна, b - емкость
|
||||
x = append(x, a) - для добавления элемента в срез
|
||||
element := x[index] - для доступа к конкретному элементу, index начинается с 0
|
||||
x[index] = element - для изменения элемента среза
|
||||
x = append(x[:index], x[index2]...) - для удаления элемента среза
|
||||
lenx = len(x) = для подсчета позиций в срезе
|
||||
.Compare(x1, x2) - для проверки равности
|
||||
.Sort(x) - для сортировки в порядке возрастания
|
||||
sort:
|
||||
.ТипПеременной(x) - для сортировки среза по возрастанию
|
||||
.SearchТипПеременной(x, 1) - для нахождения индекса числа в срезе
|
||||
sort.Sort(sort.Reverse(sort.ТипПеременной(x))) - для сортировки по убыванию
|
||||
reflect:
|
||||
reflect.DeepEqual(x1, x2) - для сравнения срезов
|
||||
os:
|
||||
.Exit(0/1) - для принудительного завершения программы
|
||||
.ReadFile(x.json) - для получения того что находится в файле x.json
|
||||
map:
|
||||
map[ТипКлюча]ТипЗначения{} - для объчвления map
|
||||
delete(x, "Ключ") - для удаления элемента из map
|
||||
x1[x2] = x3 - для добавления элемента в map
|
||||
value, ok := x1[x2] - для проверки существования элемнта в map, ok = true/false, value = значению x1[x2]
|
||||
encoding/json:
|
||||
.Unmarshal(x1, &x2) - для записи в x2 информации формата json, той сырой информации из x1, теперь можно обращаться к ней по x2.ИмяИзСтруктуры
|
||||
github.com/joho/godotenv:
|
||||
godotenv.Load() - для инита .env файла
|
||||
os.Getenv("api") - для записи в переменную значения из env файла с ключом api
|
||||
13
go/go.mod
Normal file
13
go/go.mod
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
module my-app
|
||||
|
||||
go 1.24.0
|
||||
|
||||
require (
|
||||
github.com/eclipse/paho.mqtt.golang v1.5.1 // indirect
|
||||
github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.5.1 // indirect
|
||||
github.com/gorilla/websocket v1.5.3 // indirect
|
||||
github.com/joho/godotenv v1.5.1 // indirect
|
||||
github.com/mattn/go-sqlite3 v1.14.46 // indirect
|
||||
golang.org/x/net v0.44.0 // indirect
|
||||
golang.org/x/sync v0.17.0 // indirect
|
||||
)
|
||||
14
go/go.sum
Normal file
14
go/go.sum
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
github.com/eclipse/paho.mqtt.golang v1.5.1 h1:/VSOv3oDLlpqR2Epjn1Q7b2bSTplJIeV2ISgCl2W7nE=
|
||||
github.com/eclipse/paho.mqtt.golang v1.5.1/go.mod h1:1/yJCneuyOoCOzKSsOTUc0AJfpsItBGWvYpBLimhArU=
|
||||
github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.5.1 h1:wG8n/XJQ07TmjbITcGiUaOtXxdrINDz1b0J1w0SzqDc=
|
||||
github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.5.1/go.mod h1:A2S0CWkNylc2phvKXWBBdD3K0iGnDBGbzRpISP2zBl8=
|
||||
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
|
||||
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
|
||||
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
|
||||
github.com/mattn/go-sqlite3 v1.14.46 h1:ZfaNcYO/CGNMRxkN1vvG9qf+Y+uvXfgT9a6MlEw+HmU=
|
||||
github.com/mattn/go-sqlite3 v1.14.46/go.mod h1:6JTjA44L93a0QCyJef5YvlPoKXntQPjzWv5gtm9sB6w=
|
||||
golang.org/x/net v0.44.0 h1:evd8IRDyfNBMBTTY5XRF1vaZlD+EmWx6x8PkhR04H/I=
|
||||
golang.org/x/net v0.44.0/go.mod h1:ECOoLqd5U3Lhyeyo/QDCEVQ4sNgYsqvCZ722XogGieY=
|
||||
golang.org/x/sync v0.17.0 h1:l60nONMj9l5drqw6jlhIELNv9I0A4OFgRsG9k2oT9Ug=
|
||||
golang.org/x/sync v0.17.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
|
||||
14
go/l1.go
Normal file
14
go/l1.go
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
func main() {
|
||||
read := bufio.NewReader(os.Stdin)
|
||||
fmt.Println("Your name ")
|
||||
name, _ := read.ReadString('\n')
|
||||
fmt.Println("Your name", name)
|
||||
}
|
||||
60
go/l10.go
Normal file
60
go/l10.go
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"slices"
|
||||
"unicode"
|
||||
)
|
||||
|
||||
func polz() (string, string) {
|
||||
fmt.Println("Введите первое")
|
||||
var pol1 string
|
||||
fmt.Scanln(&pol1)
|
||||
fmt.Println("Введите второе")
|
||||
var pol2 string
|
||||
fmt.Scanln(&pol2)
|
||||
return pol1, pol2
|
||||
}
|
||||
|
||||
func vowel(vow string) int {
|
||||
tolower := strings.ToLower(vow)
|
||||
wovel := 0
|
||||
for _, r := range tolower {
|
||||
if strings.ContainsRune("aeiyou", r) {
|
||||
wovel++
|
||||
}
|
||||
}
|
||||
return wovel
|
||||
}
|
||||
|
||||
func recovery(rec string) string {
|
||||
runes := []rune(rec)
|
||||
for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
|
||||
runes[i], runes[j] = runes[j], runes[i]
|
||||
}
|
||||
return string(runes)
|
||||
}
|
||||
|
||||
func anag(rec string, recc string) bool {
|
||||
runes := []rune(strings.ToLower(rec))
|
||||
runi := []rune(strings.ToLower(recc))
|
||||
slices.Sort(runes)
|
||||
slices.Sort(runi)
|
||||
return slices.Compare(runes, runi) == 0
|
||||
}
|
||||
|
||||
func format(pof1 string) string {
|
||||
runes := []rune(pof1)
|
||||
runes[0] = unicode.ToUpper(runes[0])
|
||||
return string(runes)
|
||||
}
|
||||
|
||||
func main() {
|
||||
po1, po2 := polz()
|
||||
fmt.Println("Вот колличество гласных в первом", vowel(po1))
|
||||
fmt.Println("Вот слова", po1, po2)
|
||||
fmt.Println("Вот перевернутое первое слово", recovery(po1))
|
||||
fmt.Println(anag(po1, po2))
|
||||
fmt.Println(format(po1))
|
||||
}
|
||||
38
go/l11.go
Normal file
38
go/l11.go
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
type Person struct {
|
||||
name string
|
||||
age int
|
||||
}
|
||||
|
||||
func polz() (string, int) {
|
||||
fmt.Println("Введите ваше имя")
|
||||
var pol1 string
|
||||
fmt.Scanln(&pol1)
|
||||
if pol1 == "Сергей" || pol1 == "сергей" {
|
||||
fmt.Println("Такая херь здесь не нужна")
|
||||
os.Exit(0)
|
||||
}
|
||||
fmt.Println("Введите ваш возраст")
|
||||
var pol2 int
|
||||
fmt.Scan(&pol2)
|
||||
return pol1, pol2
|
||||
}
|
||||
|
||||
func main() {
|
||||
pol1, pol2 := polz()
|
||||
pers := Person{
|
||||
name: pol1,
|
||||
age: pol2,
|
||||
}
|
||||
if pers.age == 200 {
|
||||
fmt.Println("Ваше имя:", pers.name, "\n"+"Ты", pers.age)
|
||||
} else {
|
||||
fmt.Println("Ваше имя:", pers.name, "\n"+"Твой возраст:", pers.age)
|
||||
}
|
||||
}
|
||||
26
go/l12.go
Normal file
26
go/l12.go
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
mape := map[int]string{
|
||||
1: "sergey",
|
||||
2: "sergay",
|
||||
}
|
||||
fmt.Println("Введите свое имя")
|
||||
var pol string
|
||||
fmt.Scanln(&pol)
|
||||
mape[len(mape)+1] = pol
|
||||
fmt.Println("Ваше имя:",mape[len(mape)])
|
||||
fmt.Println("Введите число значение каторого хотите увидеть")
|
||||
var i int
|
||||
fmt.Scan(&i)
|
||||
value, ok := mape[i]
|
||||
if ok {
|
||||
fmt.Println(value)
|
||||
} else {
|
||||
fmt.Println("значение",i,"не найдено, значение поиска:",ok)
|
||||
}
|
||||
}
|
||||
29
go/l13.go
Normal file
29
go/l13.go
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"encoding/json"
|
||||
"log"
|
||||
"os"
|
||||
)
|
||||
|
||||
type Json struct{
|
||||
Name string `json:"name"`
|
||||
Version int `json:"ver"`
|
||||
Active bool `json:"act"`
|
||||
}
|
||||
|
||||
func main() {
|
||||
jsonn, err := os.ReadFile("l13.json")
|
||||
if err != nil {
|
||||
log.Fatalf("Ошибка при чтении файла: %v", err)
|
||||
}
|
||||
var conf Json
|
||||
err = json.Unmarshal(jsonn, &conf)
|
||||
if err != nil {
|
||||
log.Fatalf("Ошибка при чтении файла: %v", err)
|
||||
}
|
||||
if conf.Active {
|
||||
fmt.Println("Статус:", conf.Active)
|
||||
}
|
||||
}
|
||||
5
go/l13.json
Normal file
5
go/l13.json
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"name": "program",
|
||||
"age": 2288,
|
||||
"act": true
|
||||
}
|
||||
44
go/l14.go
Normal file
44
go/l14.go
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"github.com/joho/godotenv"
|
||||
"os"
|
||||
)
|
||||
|
||||
type IPR struct{
|
||||
IP string `json:"origin"`
|
||||
}
|
||||
|
||||
func main() {
|
||||
err := godotenv.Load()
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
proxy := os.Getenv("proxy")
|
||||
proxyURL, err := url.Parse(proxy)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
tran := &http.Transport{
|
||||
Proxy: http.ProxyURL(proxyURL),
|
||||
}
|
||||
myclient := &http.Client {
|
||||
Transport: tran,
|
||||
}
|
||||
url, err := myclient.Get("https://httpbin.org/ip")
|
||||
if err != nil {
|
||||
log.Fatalf("%v\n", err)
|
||||
}
|
||||
defer url.Body.Close()
|
||||
var ipresp IPR
|
||||
err = json.NewDecoder(url.Body).Decode(&ipresp)
|
||||
if err != nil {
|
||||
log.Fatalf("%v\n", err)
|
||||
}
|
||||
fmt.Println(ipresp.IP)
|
||||
}
|
||||
78
go/l15.go
Normal file
78
go/l15.go
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"log"
|
||||
"time"
|
||||
"encoding/json"
|
||||
"github.com/joho/godotenv"
|
||||
"os"
|
||||
"net/url"
|
||||
"crypto/tls"
|
||||
)
|
||||
type MyIpData struct{
|
||||
YourIP string `json:"query"`
|
||||
City string `json:"city"`
|
||||
Country string `json:"country"`
|
||||
ISP string `json:"isp"`
|
||||
}
|
||||
type UA struct{
|
||||
UserAgent string `json:"user-agent"`
|
||||
}
|
||||
|
||||
func proxy() (bool, string) {
|
||||
err := godotenv.Load()
|
||||
if err != nil {
|
||||
return false, ""
|
||||
}
|
||||
proxy := os.Getenv("proxy")
|
||||
if proxy == "" {
|
||||
return false, ""
|
||||
}
|
||||
return true, proxy
|
||||
}
|
||||
|
||||
func main() {
|
||||
transport := &http.Transport{
|
||||
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
|
||||
}
|
||||
er, proxis := proxy()
|
||||
if er {
|
||||
proxyURL, err := url.Parse(proxis)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
transport.Proxy = http.ProxyURL(proxyURL)
|
||||
}
|
||||
fmt.Println("Введите какой хотите user-agent")
|
||||
var polz string
|
||||
fmt.Scanln(&polz)
|
||||
client := &http.Client{
|
||||
Timeout: 20 * time.Second,
|
||||
Transport: transport,
|
||||
}
|
||||
req, err := http.NewRequest("GET", "https://httpbin.org/user-agent", nil)
|
||||
if err != nil {
|
||||
log.Fatalf("%v\n", err)
|
||||
}
|
||||
req.Header.Set("User-Agent", polz)
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
log.Fatalf("%v\n", err)
|
||||
}
|
||||
req2, err := http.NewRequest("GET", "http://ip-api.com/json", nil)
|
||||
if err != nil {
|
||||
log.Fatalf("%v\n", err)
|
||||
}
|
||||
resp2, err := client.Do(req2)
|
||||
defer resp.Body.Close()
|
||||
var file UA
|
||||
err = json.NewDecoder(resp.Body).Decode(&file)
|
||||
if err != nil {
|
||||
log.Fatalf("%v\n", err)
|
||||
}
|
||||
var data MyIpData
|
||||
err = json.NewDecoder(resp2.Body).Decode(&data)
|
||||
fmt.Printf("Ваш IP: %s\nВаш город по IP: %s\nВаша страна по IP: %s\nВаш провайдер по IP: %s\nВаш User-Agent: %s\n", data.YourIP, data.City, data.Country, data.ISP, file.UserAgent)
|
||||
}
|
||||
30
go/l16.go
Normal file
30
go/l16.go
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"net/http"
|
||||
"log"
|
||||
"github.com/joho/godotenv"
|
||||
)
|
||||
|
||||
func handler(w http.ResponseWriter, r *http.Request) {
|
||||
err := godotenv.Load()
|
||||
if err != nil {
|
||||
log.Fatalf("%v\n", err)
|
||||
}
|
||||
PathFile := os.Getenv("html_file_for_l16.go") // Enter the file path for the html_file_for_l16.go variable into the env file
|
||||
html, err := os.ReadFile(PathFile)
|
||||
if err != nil {
|
||||
log.Fatalf("%v\n", err)
|
||||
}
|
||||
fmt.Fprint(w, string(html))
|
||||
}
|
||||
|
||||
func main() {
|
||||
http.HandleFunc("/VSZw5p9vwaCxQgU/efNCQ3Vz3L2P8ZGv3VWp/ybZAUeqSMbPpcDsc7G6e/", handler)
|
||||
err := http.ListenAndServe(":23455", nil)
|
||||
if err != nil {
|
||||
log.Fatalf("%v\n", err)
|
||||
}
|
||||
}
|
||||
139
go/l17.go
Normal file
139
go/l17.go
Normal file
|
|
@ -0,0 +1,139 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
mqtt "github.com/eclipse/paho.mqtt.golang"
|
||||
"github.com/joho/godotenv"
|
||||
)
|
||||
|
||||
type OpenWeather struct {
|
||||
City string `json:"name"`
|
||||
Main struct {
|
||||
Temp float64 `json:"temp"`
|
||||
FeelLike float64 `json:"feels_like"`
|
||||
} `json:"main"`
|
||||
Weather []struct {
|
||||
MainWeather string `json:"main"`
|
||||
Description string `json:"description"`
|
||||
} `json:"weather"`
|
||||
Wind struct {
|
||||
Speed float64 `json:"speed"`
|
||||
} `json:"wind"`
|
||||
}
|
||||
|
||||
func WeatherReq() (string, float64, string, float64, float64, string) {
|
||||
err := godotenv.Load()
|
||||
if err != nil {
|
||||
log.Fatalf("upload your .env file %v\n", err)
|
||||
}
|
||||
api := os.Getenv("openweathermap")
|
||||
if api == "" {
|
||||
log.Fatalf("add your openweathermap api in .env file\n")
|
||||
}
|
||||
city := os.Getenv("city_openweather")
|
||||
if city == "" {
|
||||
log.Fatalf("add your city for openweathermap in .env file\n")
|
||||
}
|
||||
client := &http.Client{
|
||||
Timeout: 20 * time.Second,
|
||||
}
|
||||
lin := "https://api.openweathermap.org/data/2.5/weather?q=" + city + "&units=metric&appid=" + api
|
||||
url := strings.ReplaceAll(lin, " ", "%20")
|
||||
req, err := http.NewRequest("GET", url, nil)
|
||||
if err != nil {
|
||||
log.Fatalf("%v\n", err)
|
||||
}
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
log.Fatalf("%v\n", err)
|
||||
}
|
||||
if resp.StatusCode != 200 {
|
||||
log.Fatalf("openweathermap return %d\n", resp.StatusCode)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
var WeatherData OpenWeather
|
||||
err = json.NewDecoder(resp.Body).Decode(&WeatherData)
|
||||
if err != nil {
|
||||
log.Fatalf("%v\n", err)
|
||||
}
|
||||
return WeatherData.City, WeatherData.Main.Temp, WeatherData.Weather[0].MainWeather, WeatherData.Wind.Speed, WeatherData.Main.FeelLike, WeatherData.Weather[0].Description
|
||||
}
|
||||
|
||||
func Send(client mqtt.Client, topic string) {
|
||||
city, temp, main, speed, feel, description := WeatherReq()
|
||||
payload := fmt.Sprintf("City: %s, Temperature: %.2f°C, Feel like %.2f°C\nWeather: %s, %s, Wind %.2fm/s", city, temp, feel, main, description, speed)
|
||||
|
||||
token := client.Publish(topic, 1, false, payload)
|
||||
token.Wait()
|
||||
if err := token.Error(); err != nil {
|
||||
log.Fatalf("%v\n", token.Error())
|
||||
} else {
|
||||
fmt.Println("Sent in", topic)
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
opts := mqtt.NewClientOptions()
|
||||
|
||||
err := godotenv.Load()
|
||||
if err != nil {
|
||||
log.Fatalf("%v\n", err)
|
||||
}
|
||||
broker := os.Getenv("broker_mqtt")
|
||||
if broker == "" {
|
||||
log.Fatalf("add yout broker in .env file\n")
|
||||
}
|
||||
ClientID := os.Getenv("clientid_mqtt")
|
||||
if ClientID == "" {
|
||||
log.Fatalf("add your client id in .env file")
|
||||
}
|
||||
topic := os.Getenv("topic_mqtt")
|
||||
if topic == "" {
|
||||
log.Fatalf("add your topic in .env file")
|
||||
}
|
||||
username := os.Getenv("login_mqtt")
|
||||
if username != "" {
|
||||
opts.SetUsername(username)
|
||||
}
|
||||
password := os.Getenv("password_mqtt")
|
||||
if password != "" {
|
||||
opts.SetPassword(password)
|
||||
}
|
||||
TimeHour := os.Getenv("TimeHourSendMQTT")
|
||||
|
||||
opts.AddBroker(broker)
|
||||
opts.SetClientID(ClientID)
|
||||
opts.SetConnectTimeout(5 * time.Second)
|
||||
|
||||
client := mqtt.NewClient(opts)
|
||||
if token := client.Connect(); token.Wait() && token.Error() != nil {
|
||||
log.Fatalf("%v\n", token.Error())
|
||||
}
|
||||
defer client.Disconnect(250)
|
||||
|
||||
fmt.Println("Connect to a broker")
|
||||
var ticker *time.Ticker
|
||||
if TimeHour != "" {
|
||||
ReallyTimeHour, err := strconv.Atoi(TimeHour)
|
||||
if err != nil {
|
||||
log.Fatalf("%s\n", err)
|
||||
}
|
||||
ticker = time.NewTicker(time.Duration(ReallyTimeHour) * time.Hour)
|
||||
} else {
|
||||
ticker = time.NewTicker(2 * time.Hour)
|
||||
}
|
||||
defer ticker.Stop()
|
||||
Send(client, topic)
|
||||
|
||||
for range ticker.C {
|
||||
Send(client, topic)
|
||||
}
|
||||
}
|
||||
45
go/l18.go
Normal file
45
go/l18.go
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
// "os"
|
||||
// "github.com/joho/godotenv"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"time"
|
||||
"bytes"
|
||||
"log"
|
||||
)
|
||||
|
||||
type Send struct{
|
||||
Name string `json:"name"`
|
||||
Age int `json:"id"`
|
||||
}
|
||||
|
||||
func main() {
|
||||
fmt.Println("Name for body")
|
||||
var name string
|
||||
fmt.Scanln(&name)
|
||||
data := Send{
|
||||
Name: name,
|
||||
Age: 66,
|
||||
}
|
||||
client := &http.Client{
|
||||
Timeout: 10 * time.Second,
|
||||
}
|
||||
body, err := json.Marshal(data)
|
||||
if err != nil {
|
||||
log.Fatalf("%v\n", err)
|
||||
}
|
||||
req, err := http.NewRequest("POST", "https://api.restful-api.dev/objects", bytes.NewBuffer(body))
|
||||
if err != nil {
|
||||
log.Fatalf("%v\n", err)
|
||||
}
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
log.Fatalf("%v\n", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
fmt.Println("Status code", resp.StatusCode)
|
||||
}
|
||||
4
go/l19/.gitignore
vendored
Normal file
4
go/l19/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
.env
|
||||
.*.*.swp
|
||||
.idea
|
||||
.vscode
|
||||
52
go/l19/l1.go
Normal file
52
go/l19/l1.go
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
type User struct{
|
||||
Age int `json:"age"`
|
||||
Name string `json:"name"`
|
||||
Email string `json:"email"`
|
||||
}
|
||||
|
||||
var setChan = make(chan User)
|
||||
|
||||
func handle(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method != http.MethodPost {
|
||||
http.Error(w, "not", http.StatusMethodNotAllowed)
|
||||
return
|
||||
}
|
||||
|
||||
var data User
|
||||
err := json.NewDecoder(r.Body).Decode(&data)
|
||||
if err != nil {
|
||||
http.Error(w,"no", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
defer r.Body.Close()
|
||||
|
||||
setChan <- data
|
||||
w.WriteHeader(http.StatusOK)
|
||||
w.Write([]byte("Data received"))
|
||||
}
|
||||
|
||||
func WatchChanell() {
|
||||
for u := range setChan {
|
||||
JsonData, err := json.Marshal(u)
|
||||
if err != nil { continue }
|
||||
fmt.Println(string(JsonData))
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
go WatchChanell()
|
||||
http.HandleFunc("/user", handle)
|
||||
fmt.Println(":7777")
|
||||
err := http.ListenAndServe(":7777", nil)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
45
go/l19/l2.go
Normal file
45
go/l19/l2.go
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"encoding/json"
|
||||
"time"
|
||||
"bytes"
|
||||
"io"
|
||||
)
|
||||
|
||||
type UserStruct struct{
|
||||
Age int `json:"age"`
|
||||
Name string `json:"name"`
|
||||
Email string `json:"email"`
|
||||
}
|
||||
|
||||
func main() {
|
||||
user := UserStruct{
|
||||
Age: 66,
|
||||
Name: "Sergey",
|
||||
Email: "Likhodeev.60@mail.ru",
|
||||
}
|
||||
JsonData, err := json.Marshal(user)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
client := &http.Client{
|
||||
Timeout: 5 * time.Second,
|
||||
}
|
||||
req, err := http.NewRequest("POST", "http://127.0.0.1:7777/user", bytes.NewBuffer(JsonData))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Printf("status code %d\n", resp.StatusCode)
|
||||
fmt.Println(string(body))
|
||||
}
|
||||
BIN
go/l19/output/l1
Executable file
BIN
go/l19/output/l1
Executable file
Binary file not shown.
26
go/l2.go
Normal file
26
go/l2.go
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
package main
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
func polz() {
|
||||
fmt.Println("Первое число ")
|
||||
var x1 int
|
||||
fmt.Scan(&x1)
|
||||
fmt.Println("Второе число ")
|
||||
var x2 int
|
||||
fmt.Scan(&x2)
|
||||
x3 := x1+x2
|
||||
fmt.Println(x1 , "+" , x2 , "=" , x3)
|
||||
}
|
||||
func main() {
|
||||
for {
|
||||
fmt.Println("1. Начать\n2. Закончить")
|
||||
var choise int
|
||||
fmt.Scan(&choise)
|
||||
if choise == 1 {
|
||||
polz()
|
||||
} else if choise == 2 {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
23
go/l3.go
Normal file
23
go/l3.go
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Println("Сколько")
|
||||
var pol string
|
||||
fmt.Scanln(&pol)
|
||||
fmt.Println("Кому?")
|
||||
var pol2 string
|
||||
fmt.Scanln(&pol2)
|
||||
|
||||
var sergay []string
|
||||
sergay = append(sergay, pol2, pol)
|
||||
if sergay[1] == "31" || sergay[1] == "21" || sergay[1] == "41" || sergay[1] == "51" || sergay[1] == "61" || sergay[1] == "71" || sergay[1] == "81" || sergay[1] == "91" || sergay[1] == "101" {
|
||||
sergay = append(sergay, "год")
|
||||
} else {
|
||||
sergay = append(sergay, "лет")
|
||||
}
|
||||
fmt.Println(sergay[0], sergay[1], sergay[2])
|
||||
}
|
||||
50
go/l4.go
Normal file
50
go/l4.go
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func logic() string {
|
||||
var phrase string
|
||||
fmt.Println("Твой возраст")
|
||||
var x int
|
||||
_, err := fmt.Scan(&x)
|
||||
if err != nil {
|
||||
phrase = "еблан"
|
||||
return phrase
|
||||
}
|
||||
switch {
|
||||
case x < 0:
|
||||
phrase = "Ты еще не родился"
|
||||
case x < 12:
|
||||
phrase = "Малолетка ебаная"
|
||||
case x >= 12 && x <= 19:
|
||||
phrase = "Ты подросток"
|
||||
case x >= 20 && x <= 65:
|
||||
phrase = "Ебать ты средний"
|
||||
case x > 65:
|
||||
phrase = "Все давай в могилу"
|
||||
default:
|
||||
phrase = "не"
|
||||
}
|
||||
return phrase
|
||||
}
|
||||
|
||||
func main() {
|
||||
fmt.Println("Как звать тебя")
|
||||
var name string
|
||||
fmt.Scanln(&name)
|
||||
for {
|
||||
fmt.Println("1. Начать\n2. Закончить")
|
||||
var pol string
|
||||
fmt.Scanln(&pol)
|
||||
if pol == "1" {
|
||||
phr := logic()
|
||||
fmt.Println("Тебя зовут", name, ",", phr)
|
||||
} else if pol == "2" {
|
||||
break
|
||||
} else {
|
||||
fmt.Println("Не то")
|
||||
}
|
||||
}
|
||||
}
|
||||
18
go/l5.go
Normal file
18
go/l5.go
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"github.com/joho/godotenv"
|
||||
"log"
|
||||
)
|
||||
|
||||
func main() {
|
||||
err := godotenv.Load()
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
return
|
||||
}
|
||||
api := os.Getenv("api_key")
|
||||
fmt.Println(api)
|
||||
}
|
||||
18
go/l6.go
Normal file
18
go/l6.go
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Println("Ты кто?")
|
||||
var pol string
|
||||
fmt.Scanln(&pol)
|
||||
ser := strings.ToLower(pol)
|
||||
if strings.HasPrefix(ser, "серг") {
|
||||
fmt.Println("Обнаружен сергей")
|
||||
} else {
|
||||
fmt.Println("Ты не сергей")
|
||||
}
|
||||
}
|
||||
18
go/l7.go
Normal file
18
go/l7.go
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
grades := []int{}
|
||||
grades = append(grades, 4, 3, 5, 2, 4, 5, 3)
|
||||
good := []int{}
|
||||
for i := len(grades) - 1; i >= 0; i-- {
|
||||
if grades[i] >= 4 {
|
||||
good = append(good, grades[i])
|
||||
grades = append(grades[:i], grades[i+1:]...)
|
||||
}
|
||||
}
|
||||
fmt.Println(grades[0:3])
|
||||
}
|
||||
29
go/l8.go
Normal file
29
go/l8.go
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func polz() []int {
|
||||
slice := []int{}
|
||||
for i := 0; i < 10; i++ {
|
||||
fmt.Println("Введите числа")
|
||||
var pol int
|
||||
fmt.Scan(&pol)
|
||||
slice = append(slice, pol)
|
||||
}
|
||||
return slice
|
||||
}
|
||||
|
||||
func main() {
|
||||
packages := polz()
|
||||
lenp := len(packages) -1
|
||||
for i := 0; i < lenp; i++ {
|
||||
for j := 1; j <= lenp - i; j++ {
|
||||
if packages[j-1] > packages[j] {
|
||||
packages[j-1], packages[j] = packages[j], packages[j-1]
|
||||
}
|
||||
}
|
||||
}
|
||||
fmt.Println(packages)
|
||||
}
|
||||
20
go/l9.go
Normal file
20
go/l9.go
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Println("Введите фразу")
|
||||
var pol string
|
||||
fmt.Scanln(&pol)
|
||||
poll := strings.ToLower(pol)
|
||||
if strings.Contains(poll, "go") {
|
||||
x := strings.Count(poll, "go")
|
||||
fmt.Println(x)
|
||||
} else {
|
||||
x2 := poll + " go"
|
||||
fmt.Println(x2)
|
||||
}
|
||||
}
|
||||
BIN
go/output/l1
Executable file
BIN
go/output/l1
Executable file
Binary file not shown.
BIN
go/output/l10
Executable file
BIN
go/output/l10
Executable file
Binary file not shown.
BIN
go/output/l11
Executable file
BIN
go/output/l11
Executable file
Binary file not shown.
BIN
go/output/l12
Executable file
BIN
go/output/l12
Executable file
Binary file not shown.
BIN
go/output/l13
Executable file
BIN
go/output/l13
Executable file
Binary file not shown.
BIN
go/output/l14
Executable file
BIN
go/output/l14
Executable file
Binary file not shown.
BIN
go/output/l15
Executable file
BIN
go/output/l15
Executable file
Binary file not shown.
BIN
go/output/l16
Executable file
BIN
go/output/l16
Executable file
Binary file not shown.
BIN
go/output/l17
Executable file
BIN
go/output/l17
Executable file
Binary file not shown.
BIN
go/output/l18
Executable file
BIN
go/output/l18
Executable file
Binary file not shown.
BIN
go/output/l2
Executable file
BIN
go/output/l2
Executable file
Binary file not shown.
BIN
go/output/l3
Executable file
BIN
go/output/l3
Executable file
Binary file not shown.
BIN
go/output/l4
Executable file
BIN
go/output/l4
Executable file
Binary file not shown.
BIN
go/output/l5
Executable file
BIN
go/output/l5
Executable file
Binary file not shown.
BIN
go/output/l6
Executable file
BIN
go/output/l6
Executable file
Binary file not shown.
BIN
go/output/l7
Executable file
BIN
go/output/l7
Executable file
Binary file not shown.
BIN
go/output/l8
Executable file
BIN
go/output/l8
Executable file
Binary file not shown.
BIN
go/output/l9
Executable file
BIN
go/output/l9
Executable file
Binary file not shown.
1
go/tg/.gitignore
vendored
Normal file
1
go/tg/.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
.env
|
||||
11
go/tg/go.mod
Normal file
11
go/tg/go.mod
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
module my-bot
|
||||
|
||||
go 1.25.0
|
||||
|
||||
require (
|
||||
github.com/PuerkitoBio/goquery v1.12.0 // indirect
|
||||
github.com/andybalholm/cascadia v1.3.3 // indirect
|
||||
github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.5.1 // indirect
|
||||
github.com/joho/godotenv v1.5.1 // indirect
|
||||
golang.org/x/net v0.52.0 // indirect
|
||||
)
|
||||
75
go/tg/go.sum
Normal file
75
go/tg/go.sum
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
github.com/PuerkitoBio/goquery v1.12.0 h1:pAcL4g3WRXekcB9AU/y1mbKez2dbY2AajVhtkO8RIBo=
|
||||
github.com/PuerkitoBio/goquery v1.12.0/go.mod h1:802ej+gV2y7bbIhOIoPY5sT183ZW0YFofScC4q/hIpQ=
|
||||
github.com/andybalholm/cascadia v1.3.3 h1:AG2YHrzJIm4BZ19iwJ/DAua6Btl3IwJX+VI4kktS1LM=
|
||||
github.com/andybalholm/cascadia v1.3.3/go.mod h1:xNd9bqTn98Ln4DwST8/nG+H0yuB8Hmgu1YHNnWw0GeA=
|
||||
github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.5.1 h1:wG8n/XJQ07TmjbITcGiUaOtXxdrINDz1b0J1w0SzqDc=
|
||||
github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.5.1/go.mod h1:A2S0CWkNylc2phvKXWBBdD3K0iGnDBGbzRpISP2zBl8=
|
||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
|
||||
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
|
||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc=
|
||||
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
|
||||
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
|
||||
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||
golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
|
||||
golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
|
||||
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
|
||||
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
|
||||
golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
|
||||
golang.org/x/net v0.52.0 h1:He/TN1l0e4mmR3QqHMT2Xab3Aj3L9qjbhRm78/6jrW0=
|
||||
golang.org/x/net v0.52.0/go.mod h1:R1MAz7uMZxVMualyPXb+VaqGSa3LIaUqk0eEt3w36Sw=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
|
||||
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
||||
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
|
||||
golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU=
|
||||
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
|
||||
golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY=
|
||||
golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
||||
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
|
||||
golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58=
|
||||
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
36
go/tg/l1.go
Normal file
36
go/tg/l1.go
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
|
||||
"github.com/joho/godotenv"
|
||||
"os"
|
||||
)
|
||||
|
||||
func main() {
|
||||
err := godotenv.Load()
|
||||
if err != nil {
|
||||
log.Fatalf("%v\n", err)
|
||||
}
|
||||
tg := os.Getenv("TG_TOKEN")
|
||||
bot, err := tgbotapi.NewBotAPI(tg)
|
||||
if err != nil {
|
||||
log.Fatalf("%v\n", err)
|
||||
}
|
||||
bot.Debug = true
|
||||
fmt.Printf("Работает как %s", bot.Self.UserName)
|
||||
u := tgbotapi.NewUpdate(0)
|
||||
u.Timeout = 60
|
||||
upd := bot.GetUpdatesChan(u)
|
||||
for update := range upd {
|
||||
if update.Message == nil {
|
||||
continue
|
||||
}
|
||||
id := update.Message.Chat.ID
|
||||
if update.Message.IsCommand() && update.Message.Command() == "start" {
|
||||
msg := tgbotapi.NewMessage(id, "Сергей")
|
||||
bot.Send(msg)
|
||||
}
|
||||
}
|
||||
}
|
||||
93
go/tg/l2.go
Normal file
93
go/tg/l2.go
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
|
||||
"github.com/joho/godotenv"
|
||||
"os"
|
||||
"log"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"encoding/json"
|
||||
"crypto/tls"
|
||||
"time"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
var userStates = make(map[int64]string)
|
||||
var Proxy = make(map[int64]string)
|
||||
|
||||
type DataIP struct {
|
||||
IP string `json:"query"`
|
||||
Country string `json:"country"`
|
||||
ISP string `json:"isp"`
|
||||
}
|
||||
|
||||
func ProxyCheck(proxy string) (bool, string, string, string) {
|
||||
proxyurl, err := url.Parse(proxy)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
transport := &http.Transport{
|
||||
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
|
||||
Proxy: http.ProxyURL(proxyurl),
|
||||
}
|
||||
client := &http.Client{
|
||||
Transport: transport,
|
||||
Timeout: 20 * time.Second,
|
||||
}
|
||||
req, err := http.NewRequest("GET", "http://ip-api.com/json", nil)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return false, "Нет", "Нет", "Нет"
|
||||
fmt.Println(err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
var data DataIP
|
||||
err = json.NewDecoder(resp.Body).Decode(&data)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
return true, data.IP, data.Country, data.ISP
|
||||
}
|
||||
|
||||
func main() {
|
||||
err := godotenv.Load()
|
||||
if err != nil {
|
||||
log.Fatalf("%v\n", err)
|
||||
}
|
||||
tg := os.Getenv("TG_TOKEN")
|
||||
bot, err := tgbotapi.NewBotAPI(tg)
|
||||
if err != nil {
|
||||
log.Fatalf("%v\n", err)
|
||||
}
|
||||
bot.Debug = true
|
||||
u := tgbotapi.NewUpdate(0)
|
||||
u.Timeout = 60
|
||||
updates := bot.GetUpdatesChan(u)
|
||||
for update := range updates {
|
||||
if update.Message == nil { continue }
|
||||
userID := update.Message.From.ID
|
||||
if update.Message.IsCommand() {
|
||||
if update.Message.Command() == "start" {
|
||||
userStates[userID] = "wating"
|
||||
bot.Send(tgbotapi.NewMessage(userID, "Введите прокси"))
|
||||
}
|
||||
continue
|
||||
}
|
||||
switch userStates[userID] {
|
||||
case "wating":
|
||||
prox := update.Message.Text
|
||||
Proxy[userID] = prox
|
||||
userStates[userID] = ""
|
||||
status, ip, country, isp := ProxyCheck(Proxy[userID])
|
||||
stat := strconv.FormatBool(status)
|
||||
msg := "Работа прокси: " + stat + "\nIP: " + ip + "\nСтрана: " + country + "\nПровайдер: " + isp
|
||||
bot.Send(tgbotapi.NewMessage(userID, msg))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
21
go/tg/l3.go
Normal file
21
go/tg/l3.go
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
)
|
||||
|
||||
func main() {
|
||||
doc, err := goquery.NewDocument("https://ru.wikipedia.org/api/rest_v1/page/mobile-html/%D0%9C%D0%BE%D1%81%D0%BA%D0%B2%D0%B0")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
doc.Find("img").Each(func(_ int, s *goquery.Selection) {
|
||||
src, exists := s.Attr("src")
|
||||
if exists {
|
||||
fmt.Println(src)
|
||||
}
|
||||
})
|
||||
}
|
||||
BIN
go/tg/output/l1
Executable file
BIN
go/tg/output/l1
Executable file
Binary file not shown.
BIN
go/tg/output/l2
Executable file
BIN
go/tg/output/l2
Executable file
Binary file not shown.
BIN
html/image.jpeg
Normal file
BIN
html/image.jpeg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 161 KiB |
75
html/l1.html
Normal file
75
html/l1.html
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>HTML</title>
|
||||
<style>
|
||||
.image {
|
||||
width: 400px;
|
||||
height: auto;
|
||||
}
|
||||
.image2 {
|
||||
text-align: centr;
|
||||
}
|
||||
.image2 {
|
||||
display: inline-block;
|
||||
margin: 10px;
|
||||
}
|
||||
body {
|
||||
background-color: black;
|
||||
color: white;
|
||||
}
|
||||
a {
|
||||
color: red;
|
||||
}
|
||||
|
||||
#about h2 {
|
||||
display: inline-block;
|
||||
width: 100%;
|
||||
}
|
||||
#about p {
|
||||
display: inline-block;
|
||||
width: 100%;
|
||||
}
|
||||
#about p sss:hover,
|
||||
#about h2 sss:hover {
|
||||
color: yellow;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<h1>Site</h1>
|
||||
</header>
|
||||
<nav>
|
||||
<a href="l2.html">Переход</a>
|
||||
<a href="l3.html">Переход 2</a>
|
||||
<a href="#about">Обо мне</a>
|
||||
</nav>
|
||||
<main>
|
||||
<div class="image2">
|
||||
<a href="https://images.prom.ua/2987667453_w1280_h640_2987667453.jpg">
|
||||
<img src="https://images.prom.ua/2987667453_w1280_h640_2987667453.jpg" alt="пушок" class="image">
|
||||
</a>
|
||||
<a href="https://esd.adventist.org/wp-content/uploads/2023/07/6-2.jpg">
|
||||
<img src="https://esd.adventist.org/wp-content/uploads/2023/07/6-2.jpg" alt="сергей" class="image">
|
||||
</a>
|
||||
<a href="https://hosadersculabon.begetcdn.cloud/photos/img_1777755980_0.png">
|
||||
<img src="https://hosadersculabon.begetcdn.cloud/photos/img_1777755980_0.png" alt="sergay" class="image">
|
||||
</a>
|
||||
<a href="https://hosadersculabon.begetcdn.cloud/photos/img_1778571936_0.jpg">
|
||||
<img src="https://hosadersculabon.begetcdn.cloud/photos/img_1778571936_0.jpg" alt="sergay" class="image">
|
||||
</a>
|
||||
</div>
|
||||
</main>
|
||||
<footer>
|
||||
<section id="about">
|
||||
<div class="color">
|
||||
<h2><sss>Я да</sss></h2>
|
||||
<p><sss>ДА да</sss></p>
|
||||
</div>
|
||||
</section>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
22
html/l2.html
Normal file
22
html/l2.html
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>HTML2</title>
|
||||
<style>
|
||||
body {
|
||||
background-color: black;
|
||||
color: blue;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<head>
|
||||
<h1>СЕРГУЛЕЧЕК</h1>
|
||||
</head>
|
||||
<main>
|
||||
<p>СЕРГУУУУНЧИК</p>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
22
html/l3.html
Normal file
22
html/l3.html
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>HTML3</title>
|
||||
<style>
|
||||
body {
|
||||
background-color: black;
|
||||
color: white;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<head>
|
||||
<h1>Сергей</h1>
|
||||
</head>
|
||||
<main>
|
||||
<p>Сергей</p>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
24
js/l1.js
Normal file
24
js/l1.js
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
let x = {
|
||||
name: "Алеша",
|
||||
age: 25
|
||||
}
|
||||
x.city = "ДА";
|
||||
console.log(x.age);
|
||||
console.log(x.name);
|
||||
console.log(x.city);
|
||||
let al = ["яблоко", "человек", "бананы"];
|
||||
console.log(al[1]);
|
||||
if(al[1] == "человек") {
|
||||
console.log("сергей");
|
||||
}
|
||||
let i = 0;
|
||||
while(1) {
|
||||
console.log("сергей");
|
||||
i++;
|
||||
if(i < 10) {
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
14
js/l2.js
Normal file
14
js/l2.js
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
const readline = require('readline').createInterface({
|
||||
input: process.stdin,
|
||||
output: process.stdout
|
||||
});
|
||||
|
||||
readline.question('Число ', (answer) => {
|
||||
let pol = Number(answer);
|
||||
readline.close();
|
||||
let x = 0;
|
||||
while(x <= 100) {
|
||||
x = x + 1;
|
||||
console.log(pol, '*', x, '=', pol * x);
|
||||
}
|
||||
});
|
||||
3
php/l1.php
Normal file
3
php/l1.php
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<?php
|
||||
echo "hello world\n";
|
||||
?>
|
||||
3
python/.gitignore
vendored
Normal file
3
python/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
.vscode
|
||||
.env
|
||||
output
|
||||
43
python/l1.py
Normal file
43
python/l1.py
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
import sys
|
||||
|
||||
pol = input('Начнем(да/нет) ')
|
||||
sp = []
|
||||
|
||||
def poll():
|
||||
pol1 = float(input('Температура: '))
|
||||
pol2 = input('Единица (C/F): ')
|
||||
if pol2=='C':
|
||||
x = pol1*1.8+32
|
||||
xx = f'{pol1}C = {x}'
|
||||
sp.append(xx)
|
||||
print(f'{pol1}C = {x}')
|
||||
elif pol2=='F':
|
||||
f = (pol1 - 32)/1.8
|
||||
ff = f'{pol1}F = {f}'
|
||||
sp.append(ff)
|
||||
print(ff)
|
||||
else:
|
||||
print('Введите верную букву')
|
||||
|
||||
def his():
|
||||
print(sp)
|
||||
|
||||
def circle():
|
||||
while True:
|
||||
if pol=='да':
|
||||
poll()
|
||||
print('1. Продолжить\n2. Закончить\n3. История')
|
||||
po = input('Число ')
|
||||
if po=='1':
|
||||
continue
|
||||
elif po=='2':
|
||||
sys.exit(1)
|
||||
elif po=='3':
|
||||
his() # Костыль
|
||||
else:
|
||||
print('Не то число')
|
||||
elif pol=='нет':
|
||||
sys.exit(1)
|
||||
else:
|
||||
print('нет')
|
||||
circle()
|
||||
65
python/l2.py
Normal file
65
python/l2.py
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
import sys
|
||||
|
||||
sp = [] # Список для истории
|
||||
|
||||
def add(a, b):
|
||||
return a + b
|
||||
|
||||
def subtract(a, b):
|
||||
return a - b
|
||||
|
||||
def multiply(a, b):
|
||||
return a * b
|
||||
|
||||
def divide(a, b):
|
||||
if b == 0:
|
||||
return 'Ошибка: деление на 0'
|
||||
return a / b
|
||||
def calculate(n1, op, n2):
|
||||
if op == '+':
|
||||
res = add(n1, n2)
|
||||
elif op == '-':
|
||||
res = subtract(n1, n2)
|
||||
elif op == '*':
|
||||
res = multiply(n1, n2)
|
||||
elif op == '/':
|
||||
res = divide(n1, n2)
|
||||
else:
|
||||
return 'Неизвестная операция'
|
||||
return res
|
||||
|
||||
def show_history():
|
||||
print('\n--- История ---')
|
||||
for i, entry in enumerate(sp[-5:], 1):
|
||||
print(f' {i}. {entry}')
|
||||
print()
|
||||
|
||||
def calc():
|
||||
while True:
|
||||
try:
|
||||
n1 = float(input('Первое число: '))
|
||||
n2 = float(input('Второе число: '))
|
||||
except ValueError:
|
||||
print('Ошибка: введите число!')
|
||||
continue
|
||||
|
||||
op = input('Операция (+, -, *, /): ')
|
||||
|
||||
result = calculate(n1, op, n2)
|
||||
if isinstance(result, str):
|
||||
print(result)
|
||||
continue
|
||||
|
||||
entry = f'{n1} {op} {n2} = {result}'
|
||||
sp.append(entry)
|
||||
print(entry)
|
||||
|
||||
pol = input('Ещё раз? (да/history/нет): ')
|
||||
if pol == 'нет':
|
||||
break
|
||||
elif pol == 'history':
|
||||
show_history()
|
||||
elif pol != 'да':
|
||||
print('Не тот выбор')
|
||||
|
||||
calc()
|
||||
Loading…
Reference in a new issue