Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- #include <vector>
- #define ARRAY_SIZE 10000
- using namespace std;
- void fill_random(int*a)
- {
- for(int i=0;i<ARRAY_SIZE;i++)
- {
- a[i]=rand();
- }
- }
- void swap(int* xp, int* yp)
- {
- int temp = *xp;
- *xp = *yp;
- *yp = temp;
- }
- void slowSort(int A[], int i, int j = ARRAY_SIZE)
- {
- if (i >= j)
- return;
- int m = (i + j) / 2;
- slowSort(A, i, m);
- slowSort(A, m + 1, j);
- if (A[j] < A[m]) {
- swap(&A[j], &A[m]);
- }
- slowSort(A, i, j - 1);
- }
- void printArray(int arr[])
- {
- int i;
- for (i = 0; i < ARRAY_SIZE; i++)
- cout << arr[i] << " ";
- cout << endl;
- }
- int main()
- {
- vector<wchar_t*> v;
- int*arr=(int*)malloc(ARRAY_SIZE*sizeof(int));
- fill_random(arr);
- slowSort(arr, 0, ARRAY_SIZE - 1);
- printArray(arr);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement