Given a positive integer n, print its corresponding column heading as it would appear in an Excel sheet. For n = 1 we have column A, for 27 we have AA and so on. - Codeprg

Breaking

programing News Travel Computer Engineering Science Blogging Earning

Monday, 29 June 2020

Given a positive integer n, print its corresponding column heading as it would appear in an Excel sheet. For n = 1 we have column A, for 27 we have AA and so on.

Given a positive integer n, print its corresponding column heading as it would appear in an Excel sheet.


Given a positive integer n, print its corresponding column heading as it would appear in an Excel sheet.
For n = 1 we have column A, for 27 we have AA and so on.


Note: The letters are all capital letters.

Input:
The first line contains an integer T, representing the total test cases. Then t lines are followed by an integer n.

Output:
For each test case, print the string corrosive to the string number, in a new line.

Restrictions:
1 ≤ t ≤ 100
1 ≤ n ≤ 107

Examples:
Input:
1
51
Output:
AY



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

int main() {
	//code
	int t;
	cin>>t;
	while(t--)
	{
	    int n;
	    cin>>n;
	     string st="";
	    while(n>0)
	    {
	       --n;
	        st=char(n%26+'A')+st;
	        n/=26;
	    }
	    cout<<st<<endl;
	}
	return 0;
}