Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //НУЖНО ПРОВЕРИТЬ ЭТУ ДИЧЬ!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- #include "pch.h"
- #include <iostream>
- #include <cmath>
- using namespace std;
- void sortmas(int k, int l, double *mas1, int s);
- int main()
- {
- int n;
- cin >> n;
- cout << "Enter n: " << endl;
- double *mas = new double[n];
- cout << "Enter mas: " << endl;
- for (int i = 0; i < n; i++)
- {
- cin >> mas[i];
- }
- double max = mas[0];
- double min = mas[0];
- int imin, imax;
- for (int i = 0; i < n; i++)
- {
- if (fabs(mas[i]) >= max)
- {
- max = mas[i];
- imax = i;
- }
- if (fabs(mas[i]) <= min)
- {
- min = mas[i];
- imin = i;
- }
- }
- sortmas(imin, imax, mas, n);
- return 0;
- }
- void sortmas(int k, int l, double *mas1, int s)
- {
- int b = 0;
- for (int i = k; i <= l - 3; i++)
- {
- for (int j = k + 1; j <= l - 2 - b; j++)
- if (mas1[j] < mas1[j + 1])
- {
- int t = mas1[j];
- mas1[j] = mas1[j + 1];
- mas1[j + 1] = t;
- }
- b++;
- }
- for (int i = 0; i < s; i++)
- {
- cout << mas1[i];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement