Please provide hint for this problem(see description)

https://mycode.prepbytes.com/problems/arrays/EDITOR1

It is just like converting a number to a base 2 or base 8. Here we have to do it for base 26 also taking care that it is converting to a string of characters, where A = 1, B = 2 and so on in decimal number system.

1 Like

hello satya_2810 , I have coded a solution for it but it’s giving wrong answer can you please check once?

#include <bits/stdc++.h>
using namespace std;

int main()
{
  //write your code here
  
  int t ; cin>>t ; 
  for(int i=0;i<t;i++)
  {
    int c ;cin>>c;
    int store =c; 
    vector<char>v; int value=1;
    while(c>0)
    {
      int ch=c%26;  
      c-=ch;
      if(ch==0)
        {
           ch=26;
          c-=26;
        }
       
      char char1=ch+64;
      v.push_back(char1);
    
     
    
        c/=26;
      
    
    }
  reverse(v.begin(),v.end());
  for(int g=0;g<v.size();g++)
    cout<<v[g]<<" ";
  cout<<endl;
    
    
  }
  
  return 0;
}

please check why my code is not correct

While you are giving the output, you don’t have to put a space between two letters.

2 Likes

see the output format in your question.

1 Like

Thanks a lot :smile:

Thanks a lot for your help :smile:

1 Like

You’re so helpful :smile:

2 Likes