蓝桥杯2019年省赛——年号字串

题目描述

本题为填空题,只需要算出结果后,在代码中使用输出语句将所填结果输出即可。

小明用字母 A 对应数字 1,B 对应 2,以此类推,用 Z 对应 26。对于 27 以上的数字,小明用两位或更长位的字符串来对应,例如 AA 对应 27,AB 对应 28,AZ 对应 52,LQ 对应 329。

请问 2019 对应的字符串是什么?

【注意】i个字母可以组合出26^i个数字。

#include
using namespace std;
char a[10];
int main()
{
	int n=2019;
	int idx=0;
	while(n)
	{
		if(n%26==0)
			a[idx++]='Z';
		else
			a[idx++]='A'+n%26-1;
		n=(n-1)/26;
	}
	for(int i=idx-1;i>=0;i--)
		cout<

【答案】BYQ

你可能感兴趣的:(蓝桥杯,c++)