#include
#include
float func(float a, float x)
{
return a * pow(a * pow(x, 7) / (cos(pow(a, 3)) + 1.31), 0.2);
}
int main()
{
float xn = 1.5, a = 2.94, xk = 5.5, dx = 0.4;
float x = xn;
int i = 0;
float min_ = func(a, xn), max_ = func(a, xn);
std::cout << "WHILE: " << std::endl;<br> while(x < xk)
{
if(min_ > func(a, x))
min_ = func(a, x);
if(max_ < func(a, x))
max_ = func(a, x);
++i;
if(i % 2 == 0)
std::cout << x << " " << func(a, x) << std::endl;<br> x += dx;
}
std::cout << "MAX - MIN: " << max_ - min_ << std::endl;<br> std::cout << std::endl << "DO WHILE: " << std::endl;<br> x = xn;
i = 0;
min_ = func(a, xn), max_ = func(a, xn);
do
{
++i;
if(min_ > func(a, x))
min_ = func(a, x);
if(max_ < func(a, x))
max_ = func(a, x);
if(i % 2 == 0)
std::cout << x << " " << func(a, x) << std::endl;<br> x += dx;
}
while(x <= xk);<br> std::cout << "MAX - MIN: " << max_ - min_ << std::endl;<br> x = xn;
i = 0;
min_ = func(a, xn), max_ = func(a, xn);
std::cout << std::endl << "FOR: " << std::endl;<br> for(i = 1; x < xk; ++i)
{
if(min_ > func(a, x))
min_ = func(a, x);
if(max_ < func(a, x))
max_ = func(a, x);
if(i % 2 == 0)
std::cout << x << " " << func(a, x) << std::endl;<br> x += dx;
}
std::cout << "MAX - MIN: " << max_ - min_ << std::endl;<br>}