From 04fd6c2065dd26ecfa8da4b8ea45406529eeb092 Mon Sep 17 00:00:00 2001 From: rhinemann Date: Mon, 16 Sep 2024 14:46:12 +0300 Subject: [PATCH] Math task finished. --- .gitignore | 1 + Makefile | 12 ++++++++++++ ll.c | 6 ++++++ maths.c | 24 ++++++++++++++++++++++++ strings.c | 6 ++++++ 5 files changed, 49 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 ll.c create mode 100644 maths.c create mode 100644 strings.c diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1de5659 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +target \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..095bb70 --- /dev/null +++ b/Makefile @@ -0,0 +1,12 @@ +CC=gcc +CFLAGS=-Wall -O3 +TDIR=target/ + +objects = strings ll +all: $(objects) maths + +maths: maths.c + $(CC) $(CFLAGS) -o $(TDIR)$@ $< -lm + +$(objects): %: %.c + $(CC) $(CFLAGS) -o $(TDIR)$@ $< \ No newline at end of file diff --git a/ll.c b/ll.c new file mode 100644 index 0000000..b453418 --- /dev/null +++ b/ll.c @@ -0,0 +1,6 @@ +#include + +int main() { + printf("Hello, World!\n"); + return 0; +} diff --git a/maths.c b/maths.c new file mode 100644 index 0000000..c51a74f --- /dev/null +++ b/maths.c @@ -0,0 +1,24 @@ +#include +#include + +// z_1 = cos(3pi / 8 - alpha / 4)^2 - cos(11pi / 8 + alpha / 4)^2 +// z_2 = sqrt(2) / 2 * sin(alpha / 2) + +int main() { + double alpha = 0, z_1 = 0, z_2 = 0; + + printf("Input Ɑ: "); + + if (scanf("%lf", &alpha) != 1){ + printf("\e[1;31m[ERROR] Alpha must be a double, restart the program.\n\e[0m"); + return 0; + } + + z_1 = cos(3 * M_PI / 8 - alpha / 4) * cos(3 * M_PI / 8 - alpha / 4) - cos(11 * M_PI / 8 + alpha / 4) * cos(11 * M_PI / 8 + alpha / 4); + z_2 = sqrt(2) / 2 * sin(alpha / 2); + + printf("z_1 = %lf\n", z_1); + printf("z_2 = %lf\n", z_2); + + return 0; +} diff --git a/strings.c b/strings.c new file mode 100644 index 0000000..b453418 --- /dev/null +++ b/strings.c @@ -0,0 +1,6 @@ +#include + +int main() { + printf("Hello, World!\n"); + return 0; +}