Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <math.h>
- #include <stdio.h>
- const double K = 22.5;
- const double L = 7.5;
- double A(double x);
- double B(double x);
- double Y(double a, double b);
- int main(void)
- {
- double x[10] = { 3.5, 7.1, 11.2, 8.5, 1.3, 4.4, 9.8, 7.1, 1.5, 10.9 };
- printf("\t\tLab5\n");
- printf("\tx\ta\t b\t y\n");
- for (int o = 0; o < 10; o++)
- {
- printf("%10.2lf", x[o]);
- if (A(x[o]) == NULL)
- {
- printf("NULL");
- }
- else {
- printf("%10.2lf", A(x[o]));
- }
- if (B(x[o]) == NULL)
- {
- printf("NULL");
- }
- else {
- printf("%10.2lf", B(x[o]));
- }
- if (Y(A(x[o]), B(x[o])) == NULL)
- {
- printf("NULL");
- }
- else {
- printf("%10.2lf\n", Y(A(x[o]), B(x[o])));
- }
- }
- }
- double A(double x)
- {
- if (x > 0)
- {
- double a = pow(pow(K, -1 / 2) - L * sqrt(x + 2.84), 2);
- return a;
- }
- else {
- return NULL;
- }
- }
- double B(double x)
- {
- if (x > 0)
- {
- double b = -log10(x) + exp(x);
- return b;
- }
- else {
- return NULL;
- }
- }
- double Y(double a, double b)
- {
- if (a == 0 || b == 0)
- {
- return NULL;
- }
- else {
- if (a > b)
- {
- double y = 4 * a + 3 * b / pow(a, 2) + pow(b, 2);
- return y;
- }
- else if (a <= b)
- {
- double y = fabs(a - b);
- return y;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement