Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Вычислить и вывести на экран в виде таблицы значение функции F на интервале Xнач. до Хкон. с шагом Xd.
- |a*i*i*i + b*i*i + c; при х<0.6 и b+c !=0
- F = < (i - a) / (i - c); при х>0.6 и b+c =0
- |i / c + i / a; в остальных случаях
- если ((int(a) || int(b) && int(c)) != 0) вывести не int, иначе int */
- #include <iostream>
- #include <conio.h>
- #include <cmath>
- #include <iomanip>
- #include <stdio.h>
- using namespace std;
- float func1(float a, float b, float c, float i){
- return a*i*i*i + b*i*i + c;
- }
- float func2(float a, float c, float i){
- return (i - a) / (i - c);
- }
- float func3(float a, float c, float i){
- return i / c + i / a;
- }
- void system(float a, float b, float c, float Xnach, float Xkon, float Xd){
- cout.setf(ios::fixed);
- cout << setprecision(1);
- cout << "___________________" << endl;
- cout << "| x | F |" << endl;
- cout << "|________|________|" << endl;
- float r;
- for (float i = Xnach; i < Xkon; i += Xd){
- if (i < 0.6 && b + c != 0)
- r=func1(a, b, c, i);
- else if (i > 0.6 && b + c == 0){
- if (i - c >= 0)
- r=func2(a, c, i);
- }
- else if (c != 0 && a != 0)
- r=func3(a, c, i);
- else continue;
- cout.width(4);
- if ((int(a) || int(b) && int(c)) != 0){
- printf_s("| %5.1f | %5.1f |\n", i, r);
- }
- else printf_s("| %5.1f | %5.1f |\n"), i, int(r);
- cout << endl;
- }
- cout << "-------------------" << endl;
- }
- int main(){
- float a, b, c, Xnach, Xkon, Xd;
- cout << "vvod a = ";
- cin >> a;
- cout << "vvod b = ";
- cin >> b;
- cout << "vvod c = ";
- cin >> c;
- cout << "vvod Xnach = ";
- cin >> Xnach;
- cout << "vvod Xkon = ";
- cin >> Xkon;
- cout << "vvod Xd = ";
- cin >> Xd;
- system(a, b, c, Xnach, Xkon, Xd);
- _getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement