Untitled
unknown
c_cpp
2 years ago
1.5 kB
8
Indexable
#include <stdio.h>
#include <math.h>
#define pi 3.14159265358979323846
#define half 90
#define pol 180
int main()
{
double x, a = (-1), chisl, znam, sin = 0, cos = 0, chisl1, znam1;
printf("enter x in degrees: ");
if (scanf_s("%lf", &x) == 1)
{
while (x >= pol || x <= -pol)
{
if (x >= pol) x -= pol;
else x += pol;
}
if(x == 90 || x == -90) printf("tg not exist");
else
{
printf("%lf", x);
printf("\n");
if (x < 180 && x > -180)
{
x = (x * pi) / pol;
for (int i = 0; i < 100; i++)
{
if (i % 2 == 1)
a = 1;
else
a = -1;
znam = 1; chisl = 1; znam1 = 1; chisl1 = 1;
for (int j = (2 * i + 1); j > 0; j--)
{
znam *= j;
chisl *= x;
}
for (int y = (2 * i); y > 0; y--)
{
znam1 *= y;
chisl1 *= x;
}
cos += (a * (chisl1 / znam1));
sin += (a * (chisl / znam));
}
printf("tg=%lf", sin / cos);
}
}
}
else
{
printf("you didn't enter a number\n");
}
return 0;
}Editor is loading...