1

(5 відповідей, залишених у C)

#include <stdio.h>
#include <math.h>
double f(double x, double a, double k) {
    double result;
    if (a == 0 || x == 0 || x == a) {
        printf("Cannot compute a function for x = %.2lf\n", x);
        return 0;
    }
    result = pow(cos(a * x), 1. / 3) + (k * log(a - x)) / log(a * x);
    return result;
}
int main() {
    double xmin, xmax, dx;
    double a, k;
    double x, y;

    printf("Enter the value xmin: ");
    scanf_s("%lf", &xmin);
    printf("Enter the value xmax: ");
    scanf_s("%lf", &xmax);
    printf("Enter the value step dx: ");
    scanf_s("%lf", &dx);
    printf("Enter the value a: ");
    scanf_s("%lf", &a);
    printf("Enter the value k: ");
    scanf_s("%lf", &k);

    printf("Tabulation function f(x):\n");
    printf("-----------------------\n");
    printf("   x      |      f(x)   \n");
    printf("-----------------------\n");

    for (x = xmin; x <= xmax; x += dx) {
        y = f(x, a, k);
        printf("%8.2lf | %10.4lf\n", x, y);
    }
    return 0;
}

як позбутися nan ind у результатах обчислення ?

2

(9 відповідей, залишених у C++)

за допомогою рекурсії знайти суму s
s = ∑(нижня межа -1, верхня межа -n)(2n-1)^2



#include <iostream>
using namespace std;

int Sum(int n) {
    
    if (n == 1) {
        return 1;
    }
    
    else {
        return (2 * n - 1) * (2 * n - 1) + Sum(n - 1);
    }
}

int main() {
    int n = 5; 
    int sum = Sum(n);
    cout << "The sum  s = " << sum << endl;
    return 0;
}

Можете сказати чи все правильно, чи як зробити щоб було краще

3

(15 відповідей, залишених у C++)

код не працює, має видати масив у якому є елементи більші за Т
Компілятор:
Size of array a: 5
Size of array b: 5
Enter elements of array a:
1 2 3 7 8
Enter elements of array b:
1 2 3 4 5

Press any key to continue . . .

4

(15 відповідей, залишених у C++)

#include <cstdlib>
#include <iostream>

using namespace std;

int main()
{
    int *a, *b, na, nb, i, T = 6, fa = 1, fb = 1;
    cout << "Size of array a: ";
    cin >> na; 
    a = (int*)calloc(na, sizeof(int)); 
    cout << "Size of array b: ";
    cin >> nb; 
    b = (int*)calloc(nb, sizeof(int)); 
    if (!a || !b) 
    {   
        
        puts("ERROR");
        return 1; 
    }
    cout << "Enter elements of array a:\n";
    for (i = 0; i < na; i++) 
    {
        cin >> *(a+i);
        if (!(*(a+i)))
            fa > T;
        
    }
    cout << "Enter elements of array b:\n";
    for (i = 0; i < nb; i++) 
    {
        cin >> *(b+i);
        if (!(*(b+i)))
            fb > T;
    }
    if (!fa)
    {
        cout << "Elements of array a:\n";
        for (i = 0; i < na; i++)
            cout << *(a +i) << " ";         
    }
    if (!fb)
    {
        cout << "Elements of array b:\n";
        for (i = 0; i < nb; i++)
            cout << *(b +i) << " ";     
    }
    free(a);  
    free(b);  
    cout << endl;
    system("PAUSE");
    return EXIT_SUCCESS;
}

5

(15 відповідей, залишених у C++)

1. Задані два масиви  A(N) і B(N) . Підрахувати в них кількість елементів, великих значення T і першим на друк вивести масив, що має найменшу їх кількість.