Problem Description
我们都知道Excel的列数是用字母表示的,比如第1列对应A,第27列对应AA。
假设给定一个正整数n,你能给出它所对应的字母表示么?
Input
程序需要读入多个测试样例,每个测试样例中:
一个正整数n(0 < n < 200000)
Output
对每个测试样例:
所对应的字母表示
Sample Input
26
171135
Sample Output
Z
ISDC
#include <stdio.h>
#include <stdlib.h>
int main()
{
int i,x,j,l,a[10000];
long int n;
while(~scanf("%ld",&n))
{
j=0;
l=0;
while(n!=0)
{
x=n%26;
if(x==0)
{
x=26;
n=n-26;//考虑到Z的n/26为1,为了控制循环减去26
}
a[j++]=x;
n=n/26;
l++;
}
for(i=l-1; i>=0; i--)
printf("%c",a[i]+'A'-1);
printf("\n");
}
return 0;
}
PS:单纯自己写的没找到平台判题,各种情况都试过了,都是对的