Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- #include<ctime>
- using namespace std;
- int main()
- {
- int n;
- cin >> n;
- double * a = new double [n];
- srand(clock());
- for (int b=0; b<n; b++)
- {
- a [b]= rand()%100 + 1;
- }
- for (int b=0; b<n; b++)
- {
- cout << a [b] << " ";
- }
- cout << endl;
- //Пузырьковая сортировка
- // for (int j = 0; j < 100; j++){
- // for (int b=0; b<n-1; b++)
- // {
- // if (a [b] > a [b+1])
- // {
- // swap (a [b] , a [b+1]);
- // }
- // }
- // }
- // for (int b=0; b<n; b++)
- // {
- // cout << a [b] << " ";
- // }
- //Создаем новый массив и копируем в него старый
- double * x = a;
- for (int b=0; b<n; b++)
- {
- cout << x [b] << " ";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement