--- /dev/null
+#include <stdio.h>
+#include <stdbool.h>
+#include <ctype.h>
+
+bool read_int(int *r)
+{
+ char c;
+ *r = 0;
+ while (isdigit(c = getchar()))
+ *r = *r*10 + c-'0';
+ return c != EOF;
+}
+
+int one(int winsize)
+{
+ int win[winsize+1], wi = 0, increase = 0;
+ for (; wi<winsize; wi++)
+ read_int(&win[wi]);
+ while (read_int(&win[wi])) {
+ if (win[wi] - win[(wi+winsize+2) % (winsize+1)] > 0)
+ increase++;
+ wi = (wi+1) % (winsize+1);
+ }
+ return increase;
+}
+
+int main(void)
+{
+ printf("%d\n", one(1));
+ return 0;
+}
int main(void)
{
- //For a
- //printf("%d\n", one(1));
- //For b
printf("%d\n", one(3));
return 0;
}
int main (void)
{
yylex();
- printf("x: %d, z: %d, x*z: %d\n", x, z, x*z);
+ printf("%d\n", x*z);
return 0;
}
CFLAGS:=-Wall -Wextra -O3
LFLAGS:=-f
-BINARIES:=01 02a 02b 03a 03b
+BINARIES:=$(foreach num,$(shell seq -f '%02.0f' 1 3),$(num)a $(num)b)
all: $(BINARIES)
clean:
$(RM) *.o a.out $(BINARIES)
+
+run: $(addprefix run_,$(BINARIES))
+
+run_%a: %a
+ ./$< < $*.txt
+
+run_%b: %b
+ ./$< < $*.txt