Jelajahi Sumber

new l15 in c folder

root 18 jam lalu
induk
melakukan
c1c29f3d73
4 mengubah file dengan 49 tambahan dan 3 penghapusan
  1. 12 0
      c/l15/govno.c
  2. 34 0
      c/l15/main.c
  3. 3 3
      go/l17.go
  4. TEMPAT SAMPAH
      go/output/l17

+ 12 - 0
c/l15/govno.c

@@ -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 - 0
c/l15/main.c

@@ -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;
+}

+ 3 - 3
go/l17.go

@@ -45,7 +45,7 @@ func WeatherReq() (string, float64, string, float64, float64, string) {
 	client := &http.Client{
 		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")
 	req, err := http.NewRequest("GET", url, nil)
 	if err != nil {
@@ -69,9 +69,9 @@ func WeatherReq() (string, float64, string, float64, float64, string) {
 
 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)
+	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()
 	if err := token.Error(); err != nil {
 		log.Fatalf("%v\n", token.Error())

TEMPAT SAMPAH
go/output/l17