This repository has been archived by the owner on Jan 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathmain.cpp
75 lines (70 loc) · 2.37 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include <iostream>
#include <math.h>
#include <fstream>
using namespace std;
const double a = 1, b1 = 0.05,b2 = 0.00001, c=0.05, d = 0.005;
double LineModel(double& y_t, double& f_t, int time);
double NoLineModel(double& y_t, double& ctime, double& f_t, int time);
int main ()
{
setlocale(LC_ALL,"RUS");
double y_t, f_t;
int time;
int number;
cout<<"Выберите модель (1- линейная, 2 - нелинейная): ";
cin>>number;
ofstream file;
file.open("Rezultat.txt");
switch(number)
{
case 1:
{
cout << "Введите начальную температуру (y_t): ";
cin >> y_t;
cout << endl;
cout << "Введите температуру(в наст момент време) (f_t): ";
cin >> f_t;
cout << endl;
cout << "Введите время (>0): ";
cin >> time;
file << "Линейная модель" << endl;
for (int i = 0; i < time; i++) {
y_t = LineModel(y_t, f_t, time);
cout << "Результат линейной функции: " << y_t << endl;
file << i << "\t" << y_t << endl;
}
file << endl;
break;
}
case 2:
{
cout << "Введите начальную температуру (y_t): ";
cin >> y_t;
cout << endl;
double ctime=0;
cout << "Введите температуру(в наст момент време) (f_t): ";
cin >> f_t;
cout << endl;
cout << "Введите время (>0): ";
cin >> time;
file<<"Нелинейная модель"<<endl;
for(int i = 0;i<time;i++){
double temp= ctime;
y_t= NoLineModel(y_t,ctime,f_t,time);
cout<<"Результат нелинейной функции: "<<y_t<<endl;
file<<i<<"\t"<<y_t<<endl;
ctime+=temp;
}
file<<endl;
break;
}
}
file.close();
return 0;
}
double LineModel(double& y_t, double& f_t, int time){
return a*y_t + b1*f_t;
}
double NoLineModel(double& y_t, double& ctime, double& f_t, int time){
return a*y_t - b2*pow(ctime,2) + c* f_t + d*sin(f_t);
}