1 семестр (Леканов) / лаба2 В14 / лр2
.odtНижегородский Государственный
Технический Университет
им. Р. Е. Алексеева
Кафедра: “Прикладная математика”
Лабораторная №2
Тема: Циклический алгоритм
Вариант: 14
Выполнил
Студент группы: 18-СП
Кондрашов Е.Н.
Проверил:
Леканов А.К.
Нижний Новгород
2018г.
Постановка задачи:
Задание 1:
Работа первая
#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;
int main()
{ double x,y;
cout.precision(5);
cout << setw(10) << "x=" << "\t" << setw(10) << "y=" << endl;
x = 1;
while (x <= 1.9)
{
y = log(1.5*x) + pow(x, 4);
cout << setw(10) << x << "\t" << setw(10) << y << endl;
x += 0.16;
}
return 0;
}
Работа вторая
#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;
int main()
{ double x,y;
cout.precision(5);
cout << setw(10) << "x=" << "\t" << setw(10) << "y=" << endl;
for (x = 1; x <= 1.9; x += 0.16)
{
y = log(1.5*x) + pow(x, 4);
cout << setw(10) << x << "\t" << setw(10) << y << endl;
}
return 0;
}
Работа третья
#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;
int main()
{ double x,y;
cout.precision(5);
cout << setw(10) << "x=" << "\t" << setw(10) << "y=" << endl;
x = 1;
do {
y = log(1.5*x) + pow(x, 4);
cout << setw(10) << x << "\t" << setw(10) << y << endl;
x += 0.16;
} while (x <= 1.9);
return 0;
}
Задание 2:
#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;
int main()
{
double x, y, z, S, P, Zmin, Zmax;
cout.precision(5);
cout << setw(10) << "x=" << "\t" << setw(10) << "y=" << "\t" << setw(10) << "z=" << endl;
P = 1;
S = 0;
Zmin = 99999;
Zmax = -99999;
for (x = 0; x <= 1.2; x += 0.7)
{
for (y = 2; y <= 7.8; y += 4.3)
{
if (x*y <= 1)
z = x*pow(sin(y),2);
else
{
if (x*y >= 5)
z = log(2*(x+y));
else
z = 1./(tan(exp(x)));
}
cout << setw(10) << x << "\t" << setw(10) << y << "\t" << setw(10) << z << endl;
S = S + z;
P = P*z;
if (Zmax < z)
Zmax = z;
if (Zmin > z)
Zmin = z;
}
}
cout << "S " << S << endl;
cout << "P " << P << endl;
cout << "Zmin= " << Zmin << endl;
cout << "Zmax= " << Zmax << endl;
return 0;
}
Задание 3:
#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;
int main()
{
double x, y, z, z1, z2;
cout.precision(5);
cout << setw(10) << "x=" << "\t" << setw(10) << "y=" << "\t" << setw(10) << "z=" << endl;
x = 1.2;
while (x <= 2.8)
{
y = -0.5;
while (y <= 0.1)
{
z1 = y*pow(x,1./2);
z2 = sin(1.47)/x;
if (z1 > z2)
z = z2;
else
z = z1;
cout << setw(10) << x << "\t" << setw(10) << y << "\t" << setw(10) << z << endl;
y += 0.45;
}
x += 1.3;
}
return 0;
}
Маткад:
1 Задание:
while for
do while
2 Задание:
3 Задание:
Блок-схема:
Задание 1:
Задание 2:
Задание 3:
Exel
Задание 1:
Задание 2:
Задание 3:
Вывод: В этой лабораторной работе я изучил циклические алгоритмы.