-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathpalindrome-r.cpp
61 lines (50 loc) · 952 Bytes
/
palindrome-r.cpp
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
/* Unsorted Array
Unlike other Coders No logic at all !
Find and run
*/
#include <bits/stdc++.h>
using namespace std;
void permute(string str, int l, int r)
{
int i;
if (l == r)
cout<<"\n"<<str;
// for(strig :: iterator = it.begin()=str.rbegin();)
else
{
for (i = l; i <= r; i++)
{
swap(str[l],str[i]) ;//(swap((a+l), (a+i));
permute(str, l+1, r);
swap(str[l],str[i]);
}
}
}
void allpalindrome(string str)
{
int l = str.length();
char mid ;
if(l%2)
{
mid = str[l/2];
}
str.resize(str.length() /2);
sort(str.begin(),str.end());
cout<<str;
if(mid)
{
cout<<mid;
}
//permuations of a string
permute(str,0,l/2-1);
}
int main()
{
string s;
cin>>s;
allpalindrome(s);
}
/*Unsorted Array
signing out all hail !
may the judge have mercy on your code
p.s @unsorted array no rights reserved */