Решения задач. (компилируется на MinGW GCC 8.1)
z1:
#include // Ввод-вывод
#include // Математические функции
double abs_double(double x) {return x < 0 ? -x : x;}
int main() {
double K, L, x, T, Q;
scanf("%lf %lf %lf", &K, &L, &x);
T = pow(cos(x)*(pow(K, 2) - pow(L, 2), 2) / (K * L * x);
Q = sqrt(pow(T, 2) * abs_double(K - L) / 0.25);
printf("T = %f, Q = %f\n", T, Q);
return 0;
}
z2:
#include // Ввод-вывод
#include // Математические функции
double max(double a, double b) {return a > b ? a : b;}
int main() {double a, n, l, x1, x2, y, z;
scanf("%lf %lf %lf", &a, &n, &l);
x1 = (a + n) / pow(a - l, 2);
x2 = a / (n * l);
if (x1 == x2) {
y = x1 * (a - n) / x2;
}
else if (x1 < x2) {
y = x1 + x2;
} else {
y = a * x1 + n * x2;
}
z = max(x1, x2) / (x1 + x2);
printf("x1 = %f, x2 = %f, y = %f, z = %f\n", x1, x2, y, z);
return 0;
}
z3:
#include
#include
int main() {
double x;
double y = 0;
scanf("%lf", &x);
for (int i = 1; i <= 11; i += 2) {<br> y += pow((x - 1) / (x + 1), i) / i;
}
printf("Y = %f", y);
}
z4:
#include
int main() {
int n = 0, p;
int sum = 0;
do {
p = n;
scanf("%d", &n);
sum += n;
} while (n != 0);
printf("sum = %d, prev = %d\n", sum, p);
return 0;
}
z5:
#include
#include
int main() {
const double PI = 3.141592;
double a;int b;
scanf("%lf %d", &a, &b);
double x, d, S, s;
if (b == 1) {
x = a;
d = x * sqrt(2);
S = pow(d / 2, 2) * PI;
s = pow(x / 2, 2) * PI;
} else if (b == 2) {
d = a;
x = d / sqrt(2);
S = pow(d / 2, 2) * PI;
s = pow(x / 2, 2) * PI;
} else if (b == 3) {
S = a;
d = 2 * sqrt(S / PI);
x = d / sqrt(2);
s = pow(x / 2, 2) * PI;
} else if (b == 4) {
s = a;
x = 2 * sqrt(s / PI);
d = x * sqrt(2);
S = pow(d / 2, 2) * PI;
} else {
printf("error");
return 0;
}
printf("x = %f, d = %f, s = %f, S = %f", x, d, s, S);
return 0;
}