Advertisement
Guest User

Untitled

a guest
Oct 25th, 2014
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.77 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3. using namespace std;
  4. int main()
  5. {
  6.     setlocale(0, "RUSSIAN");
  7.     int n;
  8.     double a;
  9.     cout << "Количество элементов: ";
  10.     cin >> n;
  11.     double *mas = new double[n];
  12.     for (int i = 0; i < n; ++i)
  13.     {
  14.         cout << "Введите " << i + 1 << "-й элемент: ";
  15.         cin >> mas[i];
  16.     }
  17.     cout << "Ввод закончен." << endl << "Введите число, элементы меньше которого будут перемещены в конец: ";
  18.     cin >> a;
  19.     for (int j = 0; j < n; ++j)
  20.     {
  21.         if (mas[j] < a)
  22.         {
  23.             for (int i = 0; i < n-1; ++i)
  24.             {
  25.                 swap(mas[i], mas[i + 1]);
  26.             }
  27.         }
  28.     }
  29.  
  30.     for (int i = 0; i < n; ++i)
  31.     {
  32.         cout << mas[i] << "\t";
  33.     }
  34.     delete[] mas;
  35.     _getch();
  36.     return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement