im not getting why my code is giving segmentation fault for some test cases like 121212…please view it…
here is the code–
#include<bits/stdc++.h>
using namespace std;
void func(string s,vector vec,int i){
if(i==s.length()){
for(unsigned int i=0;i<vec.size();i++)
cout<<char(vec[i]+64);
cout<<endl;
return ;
}
vec.push_back(s[i]-'0');
func(s,vec,i+1);
if(i<s.length()-1&&((((s[i]-'0')*10)+(s[i+1]-'0'))<=26)){
vec.erase(vec.begin()+i);
vec.push_back((((s[i]-'0')*10)+(s[i+1]-'0')));
func(s,vec,i+2);
}
}
int main(){
string s;
cin>>s;
vector<int> vec;
func(s,vec,0);
return 0;
}