Написать программу для вычисления значений функции = () в точках от x=x1 до x=xn с шагом...

0 голосов
32 просмотров

Написать программу для вычисления значений функции = () в точках от x=x1 до x=xn с шагом Δx. Для каждого варианта составить 3 программы циклической структуры с использованием for, while и do while.
Пример на рисунке 2, 3


image
image
image

Информатика (156 баллов) | 32 просмотров
Дан 1 ответ
0 голосов
Правильный ответ

1.
#include
#include

int main()
{
    float x1, xn, h;
    float a = 4, b = 7;
    printf("Введите x1, xn, h:\n"); 
    scanf("%f",&x1);
    scanf("%f",&xn);
    scanf("%f",&h);
    for (float x=x1; x<=xn; x +=h)<br>        printf("x = %.2f  y = %.5f\n",x,b*x*sqrt(1+log(x)));
    return 0;
}

2.
#include
#include

int main()
{
    float x1, xn, h, x;
    float a = 4, b = 7;
    printf("Введите x1, xn, h:\n"); 
    scanf("%f",&x1);
    scanf("%f",&xn);
    scanf("%f",&h);
    x = x1;
    while (x<=xn){<br>        printf("x = %.2f  y = %.5f\n",x,b*x*sqrt(1+log(x)));
        x += h;
    }
    return 0;
}

3.
#include
#include

int main()
{
    float x1, xn, h, x;
    float a = 4, b = 7;
    printf("Введите x1, xn, h:\n"); 
    scanf("%f",&x1);
    scanf("%f",&xn);
    scanf("%f",&h);
    x = x1;
    do {
        printf("x = %.2f  y = %.5f\n",x,b*x*sqrt(1+log(x)));
        x += h;
    }
    while (x<=xn);<br>    return 0;
}

Пример:
Введите x1, xn, h:
2
5
0.1
x = 2.00 y = 18.21694
x = 2.10 y = 19.40142
x = 2.20 y = 20.59491
...
x = 4.90 y = 55.19244
x = 5.00 y = 56.53810

(194k баллов)