Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.99 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3. #include<ctime>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     int n;
  10.     cin >> n;
  11.     double * a = new double [n];
  12.     srand(clock());
  13.         for (int b=0; b<n; b++)
  14.         {
  15.             a [b]= rand()%100 + 1;
  16.         }
  17.         for (int b=0; b<n; b++)
  18.         {
  19.             cout << a [b] << " ";
  20.         }
  21.  
  22.         cout << endl;
  23. //Пузырьковая сортировка
  24. //        for (int j = 0; j < 100; j++){
  25. //            for (int b=0; b<n-1; b++)
  26. //            {
  27. //                if (a [b] > a [b+1])
  28. //                {
  29. //                    swap (a [b] , a [b+1]);
  30. //                }
  31. //            }
  32. //        }
  33.  
  34. //        for (int b=0; b<n; b++)
  35. //        {
  36. //            cout << a [b] << " ";
  37. //        }
  38.  
  39.         //Создаем новый массив и копируем в него старый
  40.      double * x = a;
  41.      for (int b=0; b<n; b++)
  42.      {
  43.          cout << x [b] << " ";
  44.      }
  45.     return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement