new l15 in c folder
This commit is contained in:
parent
3cd8660746
commit
c1c29f3d73
4 changed files with 49 additions and 3 deletions
12
c/l15/govno.c
Normal file
12
c/l15/govno.c
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int zzz(int i, int x, char *str) {
|
||||||
|
while(1) {
|
||||||
|
printf("%s\n", str);
|
||||||
|
i++;
|
||||||
|
if(i == x) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
34
c/l15/main.c
Normal file
34
c/l15/main.c
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include "govno.c"
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int ot;
|
||||||
|
int doo;
|
||||||
|
char str[100];
|
||||||
|
} Polz;
|
||||||
|
|
||||||
|
Polz polz() {
|
||||||
|
Polz ret;
|
||||||
|
printf("От ");
|
||||||
|
scanf("%d", &ret.ot);
|
||||||
|
if(ret.ot < 0) {
|
||||||
|
ret.ot = 0;
|
||||||
|
}
|
||||||
|
printf("До ");
|
||||||
|
scanf("%d", &ret.doo);
|
||||||
|
if(ret.ot > ret.doo) {
|
||||||
|
printf("НЕКОРРЕКТНО\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
printf("Что ");
|
||||||
|
scanf("%99s", ret.str);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
Polz r = polz();
|
||||||
|
zzz(r.ot, r.doo, r.str);
|
||||||
|
printf("\nГОЙДА ЕСТЬ\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
@ -45,7 +45,7 @@ func WeatherReq() (string, float64, string, float64, float64, string) {
|
||||||
client := &http.Client{
|
client := &http.Client{
|
||||||
Timeout: 20 * time.Second,
|
Timeout: 20 * time.Second,
|
||||||
}
|
}
|
||||||
lin := "https://api.openweathermap.org/data/2.5/weather?q=" + city + "&units=metric&appid=" + api
|
lin := "https://api.openweathermap.org/data/2.5/weather?q=" + city + "&units=metric&appid=" + api + "&lang=ru"
|
||||||
url := strings.ReplaceAll(lin, " ", "%20")
|
url := strings.ReplaceAll(lin, " ", "%20")
|
||||||
req, err := http.NewRequest("GET", url, nil)
|
req, err := http.NewRequest("GET", url, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -69,9 +69,9 @@ func WeatherReq() (string, float64, string, float64, float64, string) {
|
||||||
|
|
||||||
func Send(client mqtt.Client, topic string) {
|
func Send(client mqtt.Client, topic string) {
|
||||||
city, temp, main, speed, feel, description := WeatherReq()
|
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)
|
payload := fmt.Sprintf("Город: %s, Температура: %.2f°C, Ощущается %.2f°C\nПогода: %s, %s, Ветер %.2fm/s", city, temp, feel, main, description, speed)
|
||||||
|
|
||||||
token := client.Publish(topic, 1, false, payload)
|
token := client.Publish(topic, 2, false, payload)
|
||||||
token.Wait()
|
token.Wait()
|
||||||
if err := token.Error(); err != nil {
|
if err := token.Error(); err != nil {
|
||||||
log.Fatalf("%v\n", token.Error())
|
log.Fatalf("%v\n", token.Error())
|
||||||
|
|
|
||||||
BIN
go/output/l17
BIN
go/output/l17
Binary file not shown.
Loading…
Reference in a new issue