Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- // #include <complex.h>
- #include <math.h>
- /*
- double logbase(double a, double base)
- {
- return log(a) / log(base);
- }
- */
- int main()
- {
- /*
- x, s = 0;
- ap = x;
- s += ap;
- y = ;
- an = ap*y;
- ap = an;
- an > e;
- */
- printf("\nВведите x:\n");
- double x;
- scanf("%lf", &x);
- // double target = x;
- double sum = 0;
- double n = 1;
- // double a = 1;
- printf("\nВведите E (точность числа, ex:0.001):\n");
- double e;
- scanf("%lf", &e);
- double an;//, ap;
- //ap = x;
- an = x;
- do
- {
- sum += an;
- //ap = an;
- an = an * (-(x*x)/(2*n*(2*n+1)));
- //ap = an;
- n += 1;
- printf("элемент(%d): %lf\t| сумма: %lf\n", (int)n, an, sum);
- } while (fabs(an) > e);
- printf("\nОтвет: %lf. От библиотеки math.h: %lf\n\n", sum, sin(x));
- /*
- printf("\nВведите дробное число:\n\n");
- double num;
- scanf("%lf", &num);
- printf("\nВведите степень:\n\n");
- double degree;
- scanf("%lf", °ree);
- printf("\nОтвет:%lf\n", exp(degree * log(num)));
- */
- /*
- // лаба 5
- printf("\nВведите дробное число:\n\n");
- double target;
- scanf("%lf", &target);
- double i = 0.5; // 1/(2^n)
- int r = 0;
- printf("0.");
- while (target - i != 0 && limit != 0){
- if (i <= target){
- printf("1");
- limit -= 1;
- target -= i;
- } else printf("0");
- i /= 2;
- }
- printf("1\nГотово.\n\n\n");
- */
- /*
- // лаба 5
- printf("Введите коэффициенты при X квадратного уравнения, вида AX^2 + BX + C = 0.\n\n");
- double a, b, c;
- double complex d, x1, x2;
- printf("\nВведите A: ");
- scanf("%lf", &a);
- printf("Введите B: ");
- scanf("%lf", &b);
- printf("Введите C: ");
- scanf("%lf", &c);
- if (a != 0){
- d = csqrt(b * b - (4 * a * c));
- x1 = (-b + d) / (2.0*a);
- x2 = (-b - d) / (2.0*a);
- printf("\nx1 = %.2f + (%.2fi);\nx2 = %.2f + (%.2fi);", creal(x1), cimag(x1), creal(x2), cimag(x2));
- } else {
- if (b == 0) printf("Перезапустите программу заново и повторите ввод коэффициентов при X, исключая, что a=0 и b=0.");
- else printf("x = %.2f;", -(c/b));
- }
- printf("\n");
- */
- /* // лаба 4
- double x,y;
- printf("\nВведите x: ");
- scanf("%lf", &x);
- printf("Введите y: ");
- scanf("%lf", &y);
- if (x < 0.0 && y < 0.0){
- x = fabs(x);
- y = fabs(y);
- } else {
- if ((x > 0.0 && y < 0.0) || (x < 0.0 && y > 0.0)) {
- x *= 0.5;
- y *= 0.5;
- } else {
- if ((x >= 0.5 && x <= 2.0) && (y >= 0.5 && y <= 2.0)) {
- x /= 10.0;
- y /= 10.0;
- }
- }
- }
- printf("x = %lf; y = %lf\n", x, y);
- */
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement