I think the logic is correct but I am unable to print the answer in the desired format, one extra space and comma is coming, how to remove it.
#include <bits/stdc++.h>
using namespace std;
void print(char* inp,char* out,int i,int j){
if(inp[i]==0){
out[j]=0;
cout<<out<<", ";
return;
}
int a=inp[i]-'0';
if(a==0)return;
if(a>0){
out[j]='a'+a-1;
print(inp,out,i+1,j+1);
}
if(inp[i+1]!=0){
int b=inp[i+1]-'0';
int no = a*10+b;
if(no>26)return;
if(no<1)return;
out[j]='a'+no-1;
print(inp,out,i+2,j+1);
}
return;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
char s[1000];
cin>>s;
char ans[1000];
cout<<'[';
print(s,ans,0,0);
cout<<"]";
return 0;
}