-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSpecificOrderSort.cpp
More file actions
75 lines (63 loc) · 1007 Bytes
/
Copy pathSpecificOrderSort.cpp
File metadata and controls
75 lines (63 loc) · 1007 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include <iostream>
#include<stdlib.h>
#include<bits/stdc++.h>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char** argv) {
int n,count=0,count1=0,t,temp,v;
cin>>t;
while(t--)
{
cin>>n;
count=0;
count1=0;
int a[n];
int asc[n]={0};
int des[n]={0};
for(int i=0;i<n;i++)
{
cin>>a[i];
}
//sort(a,a+n);
for(int i=0;i<n;i++)
{
if(a[i]%2!=0)
{
des[count]=a[i];
count++;
}
else
{
asc[count1]=a[i];
count1++;
}
}
sort(asc,asc+count1);
sort(des,des+count,greater<int>());
for(int i=0;i<n;i++)
{
cout<<des[i];
}
cout<<endl;
for(int i=0;i<n;i++)
{
cout<<asc[i];
}
int m=count+count1;
int merge[m];
for(int i=0;i<m;i++)
{
merge[i]=des[i];
}
for(int i=0;i<=count1;i++)
{
merge[count+1]=asc[i];
count++;
}
for(int i=0;i<m;i++)
{
cout<<merge[i];
}
}
return 0;
}