Math task finished.

This commit is contained in:
rhinemann 2024-09-16 14:46:12 +03:00
commit 04fd6c2065
5 changed files with 49 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
target

12
Makefile Normal file
View File

@ -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)$@ $<

6
ll.c Normal file
View File

@ -0,0 +1,6 @@
#include <stdio.h>
int main() {
printf("Hello, World!\n");
return 0;
}

24
maths.c Normal file
View File

@ -0,0 +1,24 @@
#include <stdio.h>
#include <math.h>
// 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;
}

6
strings.c Normal file
View File

@ -0,0 +1,6 @@
#include <stdio.h>
int main() {
printf("Hello, World!\n");
return 0;
}