4.marko.18_test.coder 4.egor.18_test.coder

--- 4.marko.18_test.coder.fmt.c	2020-06-08 11:39:11.774116099 +0300
+++ 4.egor.18_test.coder.fmt.c	2020-06-08 11:39:11.727115591 +0300
@@ -1,33 +1,29 @@
 #1 "<stdin>"
-#include <stdio.h>
+#include <string.h>
+#include <errno.h>
 #include <sys/types.h>
+#include <unistd.h>
+#include <stdio.h>
 #include <signal.h>
 #include <stdlib.h>
-#include <errno.h>
-#include <string.h>
-#include <unistd.h>
 int main(int argc, char *argv[]) {
-    int i = 0;
-    int m = 128;
+    int sygnal = 0;
     while (1) {
-	char c = argv[2][i];
-	char cc = c;
-	for (int j = 0; j < 8; j++) {
-	    int sign;
-	    if ((m & c) == 128)
-		sign = SIGUSR2;
+	char zero = argv[2][sygnal];
+	char one = argv[2][sygnal];
+	int pid = (atoi(argv[1]));
+	for (int k = 7; k >= 0; k--) {
+	    int x = (zero >> (k)) & 0x1;
+	    if (x == 1)
+		kill(pid, SIGUSR2);
 	    else
-		sign = SIGUSR1;
-	    if (kill(atoi(argv[1]), sign)) {
-		perror("Kill problem:");
-		exit(1);
-	    }
-	    usleep(1000);
-	    c = c << 1;
+		kill(pid, SIGUSR1);
+	    usleep(10000);
+	    zero = zero << 1;
 	}
-	if (cc == '\0')
+	if (one == 0)
 	    break;
-	i++;
+	sygnal++;
     }
     return 0;
 }