Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #include <stdio.h>
- #include<stdlib.h>
- using namespace std;
- void twoWaySort(int arr[], int n)
- {
- int l = 0, r = n-1;
- int k = 0;
- while (l < r)
- {
- while (arr[l]%2 != 0)
- {
- l++;
- k++;
- }
- while (arr[r]%2 == 0 && l<r)
- r--;
- if (l < r)
- swap(arr[l], arr[r]);
- }
- sort(arr, arr+k, greater<int>());
- sort(arr+k, arr+n);
- }
- int main()
- {
- int arr[][4]={
- {25,64,96,32},
- {50,12,69,78},
- {12,14,65,89},
- {28,27,97,12}
- };
- int i,k;
- int n;
- for(i=0;i<4;i++)
- {for(n=0;n<4;n++)
- {
- printf("arr[%d][%d]",i,n);
- scanf("%d%d",arr[i][n]);
- }
- }
- system("cls");
- twoWaySort(arr ,n);
- for (int i=0; i<n; i++)
- printf("%d\n",arr[i][n]);
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement