Загрузка данных


#include <stdio.h>
#include <math.h>

int main() {
    float A = 1.5;
    int N;
    float dx = 3 * A / 10.0;  // dx = 0.45
    double y, x;
    x = -A;  // x начальный = -1.5

    printf("Введите количество значений N: ");
    scanf("%d", &N);

    printf("\n==== Табулирование функции ====\n");
    printf("+------------+--------------+\n");
    printf("|     x      |      y       |\n");
    printf("+------------+--------------+\n");

    for (int i = 0; i <= N; i++) {
        if (x < 0) {
            // y = 2A * sqrt(1 - x^2/A^2)
            y = 2 * A * sqrt(1 - (x * x) / (A * A));
        }
        else {
            // y = A/2 * cos(x) + 3A/2
            y = (A / 2.0) * cos(x) + (3 * A / 2.0);
        }

        if (isnan(y) == 1)
            printf("|%10.2f  |  Undefined   |\n", x);
        else
            printf("|%10.2f  | %12.4f |\n", x, y);

        x = x + dx;
    }

    printf("+------------+--------------+\n");
    getchar();
    return 0;
}