Skip to content

Commit

Permalink
Update main.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
alexsandro007 authored Sep 15, 2024
1 parent deb953b commit 7f8356b
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions trunk/as0006325/task_01/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

using namespace std;

// Ôóíêöèÿ äëÿ ëèíåéíîé ìîäåëè
// Function for linear model
void linearModel(double y, double u, double a, double b, int steps) {
for (int i = 1; i <= steps; i++) {
double y_next = a * y + b * u;
Expand All @@ -13,7 +13,7 @@ void linearModel(double y, double u, double a, double b, int steps) {
}
}

// Ôóíêöèÿ äëÿ íåëèíåéíîé ìîäåëè
// Function for nonlinear model
void nonlinearModel(double y, double u, double a, double b, double c, double d, int steps) {
double y_prev = 0;
double u_prev = 0;
Expand All @@ -22,18 +22,18 @@ void nonlinearModel(double y, double u, double a, double b, double c, double d,
double y_next = a * y - b * y_prev * y_prev + c * u + d * sin(u_prev);
cout << "Step " << i << ": y = " << y_next << endl;

y_prev = y; // Îáíîâëÿåì ïðåäûäóùåå çíà÷åíèå òåìïåðàòóðû
u_prev = u; // Îáíîâëÿåì ïðåäûäóùåå çíà÷åíèå óïðàâëåíèÿ
y_prev = y; // Update the previous temperature value
u_prev = u; // Update the previous control value

y = y_next; // Îáíîâëÿåì òåêóùåå çíà÷åíèå òåìïåðàòóðû
y = y_next; // Update the current temperature value
}
}

int main() {
double a, b, c, d; // Êîíñòàíòû
double y; // Òåêóùàÿ òåìïåðàòóðà
double u; // Òåêóùàÿ òåïëîòà
int steps; // Êîëè÷åñòâî øàãîâ ìîäåëèðîâàíèÿ
double a, b, c, d; // Constants
double y; // Current temperature
double u; // Current heat
int steps; // Number of modeling steps

cout << "Enter the value for constant a: "; cin >> a;
cout << "Enter the value for constant b: "; cin >> b;
Expand All @@ -45,13 +45,13 @@ int main() {

cout << "Enter the number of iterations, steps: "; cin >> steps;

// Ëèíåéíàÿ ìîäåëü
// Linear model
cout << "\nLinear model simulation:\n";
linearModel(y, u, a, b, steps);

// Íåëèíåéíàÿ ìîäåëü
// Nonlinear model
cout << "\nNonlinear model simulation:\n";
nonlinearModel(y, u, a, b, c, d, steps);

return 0;
}
}

0 comments on commit 7f8356b

Please sign in to comment.