#include
#include
using namespace std;
#define N 100
void pre2post(char pre[] , int preL,int preR , char post[] , int postL , int postR)
{
if(preL <= preR)
{
post[postR] = pre[preL];
int halfpos = (preR - preL) / 2;
pre2post(pre , preL+1 , preL + halfpos, post , postL ,postL + halfpos - 1);
pre2post(pre , preL+halfpos+1 , preR, post , postL + halfpos ,postR-1);
}
}
int main()
{
char pre[N] = "ABDECFG";
char post[N];
pre2post(pre,0,6, post, 0 ,6);
for(int i = 0 ; i <= 6 ; i ++)
{
printf("%c ", post[i]);
}
return 0;
}