Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<string>
- #include<set>
- using namespace std;
- char arr[] = {'0', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y','Z'};
- set<string> se;
- void print(int * a, int n, int pos, string s ){
- if(pos > n){
- // cout<<"Ret 1"<<endl;
- return;
- }
- if(pos == n-1){
- string newstr = s;
- // cout<<"Ret 2"<<endl;
- if(a[pos]< 27 && a[pos]>=1){
- // { cout<<"Ret 3"<<endl;
- newstr += arr[a[pos]];
- cout<<newstr<<endl;
- se.insert(newstr);
- }
- return;
- }
- if(pos >= n-2){
- // cout<<"Ret 4"<<endl;
- if(a[pos] <= 2 && a[pos+1] < 7){
- // cout<<"Ret 5"<<endl;
- string newstr = s;
- int num = a[pos]*10 + a[pos+1];
- newstr += arr[num];
- cout<<newstr<<endl;
- se.insert(newstr);
- }
- string newstr = s;
- //as that . is already computed above
- if(a[pos] == 0 || a[pos+1] == 0){
- // cout<<"Ret 6"<<endl;
- return;
- }
- newstr += arr[a[pos]];
- newstr += arr[a[pos+1]];
- // cout<<"Ret 7"<<endl;
- cout<<newstr<<endl;
- se.insert(newstr);
- return;
- }
- if(pos < n - 2 && a[pos]<=2 && a[pos+1]<7){
- // cout<<"Ret 8"<<endl;
- string newstr = s;
- int num = a[pos]*10 + a[pos+1];
- newstr += arr[num];
- // cout<<newstr<<endl;
- print(a, n, pos+2, newstr);
- }
- s += arr[a[pos]];
- // cout<<"Bottom"<<endl; // cout<<s<<endl;
- if(pos == n-1){
- // cout<<"Ret 10"<<endl;
- cout<<s<<endl;
- se.insert(s);
- return;
- }
- print(a, n, pos+1, s);
- return;
- }
- int main(){
- string s;
- cin>>s;
- int n = s.length();
- int a[s.length()];
- for(int i = 0; i < n; i++){
- a[i] = s[i] - '0';
- // cout<<a[i]<<endl;
- }
- print(a, n, 0, "");
- // Problem : These line below are giving many errors don't know why
- // set <int > :: iterator itr;
- // for (itr = se.begin(); itr != se.end(); ++itr)
- // {
- // cout << *itr<<endl;
- // }
- return 0;
- }
Add Comment
Please, Sign In to add comment