Answer the question
In order to leave comments, you need to log in
Why is the array not sorted by "insertions" method?
Why is the y array not sorted? It is necessary by the "inserts" method.
#include<iostream>
#include <cstring>
#include<cmath>
#include<cstdlib>
#include<conio.h>
#include<ctime>
#include<windows.h>
using namespace std;
int main()
{
setlocale(LC_ALL, "");
const int n = 5;
int x[n], y[n], i, j, temp, max = -1000, min = 1000, a, b;
cout << "Введите 2 значения для вычесления = " << endl;
cin >> a;
cin >> b;
cout << "Массив x " << endl;
for (int i = 0; i < n; i++)
{
x[i] = rand() % 20 - 10;
cout << "x[" << i << "] = " << x[i] << endl;
}
cout << endl;
for (i = 0; i < n; i++)
{
y[i] = a / x[i] - b / sin(pow(a, 2.0));
if (y[i] > max)
{
max = y[i];
}
if (y[i] < min)
{
min = y[i];
}
}
for (i = 0; i < n; i++)
{
temp = y[i];
for (j = i - 1; j >= 0 && y[i] > temp; j--)
{
y[j + 1] = y[j];
y[j + 1] = temp;
}
}
for (i = 0; i < n; i++)
{
cout << "y [ " << i << " ] = " << y[i] << endl;
}
cout << "Минимальное значение массива = " << min << endl;
cout << "Максимальное значение массива = " << max << endl;
system("PAUSE");
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question