-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMaqSoftware.cpp
More file actions
47 lines (46 loc) · 1.11 KB
/
MaqSoftware.cpp
File metadata and controls
47 lines (46 loc) · 1.11 KB
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
/*
SORT THE STRING IN THESE CONDITIONS:
1) Smaller letter shold come first in sorted order (a-z)
2) Larger letters should come next in sorted order (A-Z)
3) Numbers should come next but odd numbers should be placed first then the even numbers (Not necessarily in sorted order)
4) If any special characters are present remove them
Eg:
i/p: ekTRYFFoi876
o/p: eikoFFRTY786
*/
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
string a;
cin>>a;
string str="";
string capstr="";
string numstr="";
string after="";
int n=a.length();
for(int i=0;i<n;i++)
{
if(a[i]>='a' and a[i]<='z')
{
str=str+a[i];
}
if(a[i]>='A' and a[i]<='Z')
{
capstr=capstr+a[i];
}
if(isdigit(a[i]))
{
if(a[i]%2!=0)
{
numstr=numstr+a[i];
}
else
after=after+a[i];
}
}
sort(str.begin(), str.end());
sort(capstr.begin(), capstr.end());
cout<< str+capstr+numstr+after;
}