Math task finished.
This commit is contained in:
commit
04fd6c2065
|
@ -0,0 +1 @@
|
|||
target
|
|
@ -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)$@ $<
|
|
@ -0,0 +1,6 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main() {
|
||||
printf("Hello, World!\n");
|
||||
return 0;
|
||||
}
|
|
@ -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;
|
||||
}
|
Loading…
Reference in New Issue