
C/C++
Нужно срочно решить задачу на C++

#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
double real(const char* msg) {
cout << msg;
double value;
cin >> value;
return value;
}
int main() {
const auto a = real("a: ");
const auto b = real("b: ");
const auto c = real("c: ");
const auto xn = real("Xнач: ");
const auto xk = real("Xкон: ");
const auto dx = real("dx: ");
const auto end = xk + dx / 10.0;
cout.setf(ios::fixed);
for (auto x = xn; x <= xk; x += dx) {
if (fabs(x) < 1e-15) x = 0;
double f = a + x / c;
if (!x) {
if (b) f = a * c * c - b;
else f = -a / -c;
}
cout << "F(" << setprecision(2) << x << "): " << setprecision(4) << f << '\n';
}
}
#include <iomanip>
#include <cmath>
using namespace std;
double real(const char* msg) {
cout << msg;
double value;
cin >> value;
return value;
}
int main() {
const auto a = real("a: ");
const auto b = real("b: ");
const auto c = real("c: ");
const auto xn = real("Xнач: ");
const auto xk = real("Xкон: ");
const auto dx = real("dx: ");
const auto end = xk + dx / 10.0;
cout.setf(ios::fixed);
for (auto x = xn; x <= xk; x += dx) {
if (fabs(x) < 1e-15) x = 0;
double f = a + x / c;
if (!x) {
if (b) f = a * c * c - b;
else f = -a / -c;
}
cout << "F(" << setprecision(2) << x << "): " << setprecision(4) << f << '\n';
}
}
ответ 2
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
double real(const char* msg) {
cout << msg;
double value;
cin >> value;
return value;
}
int main() {
const auto a = real("a: ");
const auto b = real("b: ");
const auto c = real("c: ");
const auto xn = real("Xнач: ");
const auto xk = real("Xкон: ");
const auto dx = real("dx: ");
const auto end = xk + dx / 10.0;
cout.setf(ios::fixed);
for (auto x = xn; x <= xk; x += dx) {
if (fabs(x) < 1e-15) x = 0;
double f = a + x / c;
if (!x) {
if (b) f = a * c * c - b;
else f = -a / -c;
}
cout << "F(" << setprecision(2) << x << "): " << setprecision(4) << f << '\n';
}
}
#include <iomanip>
#include <cmath>
using namespace std;
double real(const char* msg) {
cout << msg;
double value;
cin >> value;
return value;
}
int main() {
const auto a = real("a: ");
const auto b = real("b: ");
const auto c = real("c: ");
const auto xn = real("Xнач: ");
const auto xk = real("Xкон: ");
const auto dx = real("dx: ");
const auto end = xk + dx / 10.0;
cout.setf(ios::fixed);
for (auto x = xn; x <= xk; x += dx) {
if (fabs(x) < 1e-15) x = 0;
double f = a + x / c;
if (!x) {
if (b) f = a * c * c - b;
else f = -a / -c;
}
cout << "F(" << setprecision(2) << x << "): " << setprecision(4) << f << '\n';
}
}