include <iostream>
include <stdio.h>
include <cstdlib>
include <string.h>
using namespace std;
int main() { int t; // cin>>t;
char ch[401];
int i=0,j;
scanf("%s",ch);
getchar();
for(i=0;i<strlen(ch);i++)
{
if(ch[i]>=97&&ch[i]<=122)
printf("%c",ch[i]);
if(ch[i]==')') // ((a+t)*((b+(a+c))^(c+d)))
{
j=i;
while(ch[j]!='+'||ch[j]!='-'||ch[j]!='*'||ch[j]!='^')
j--;
printf("%c",ch[j]);
ch[j]=32;
}
}
return 0;
}
Logic :
example : ((a+t)*((b+(a+c))^(c+d)))
check each element of the string and as an alphabet appears , print it, and if ')' appears , go back fetching for operators, and as you find the operator, print it.