Advertisement
Mlack

Untitled

May 9th, 2014
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4. #include <cstddef>
  5. #include <ctime>
  6.  
  7. typedef long long lln;
  8.  
  9. int compare(const void *a, const void *b) {
  10.     return (*(int*)a - *(int*)b);
  11. }
  12.  
  13. using namespace std;
  14.  
  15. int main()
  16. {
  17.     srand(time(NULL));
  18. //    vector<int> v1;
  19.     lln n;
  20.     cin >> n;
  21.     int *mas = new int[n];
  22.     for(int i = 0; i < n; ++i) {
  23.         mas[i] = rand() % 100;
  24.     }
  25.     qsort(mas, n, sizeof(int),  compare);
  26.     for(int i = 0; i < n; ++i)
  27.         cout << mas[i] << " ";
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement