当前位置:网站首页>精彩编码 【进制转换】
精彩编码 【进制转换】
2022-07-06 11:47:00 【全栈程序员站长】
大家好,又见面了,我是全栈君。
精彩编码 Description 如果没有阿拉伯数字,我们想得到怎样来表示数字 小明觉得一个方法,如下面的: 1 -> A 2 -> B 3 -> C …. 25 -> Y 26 -> Z 27 -> AA
28 -> AB ….
如今请你写一个程序完毕这个转换
Input 输入的第一个数为一个正整数T,表明接下来有T组数据。 每组数据为一个正整数n ( n <= 1000)
Output 对于每一个正整数n,输出他相应的字符串
Sample Input 3 1 10 27 Sample Output A J AA
进制转换?
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <stdlib.h>
#include <ctype.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <queue>
#include <stack>
#include <set>
#include <sstream>
#include <time.h>
#include <utility>
#include <malloc.h>
#include <stdexcept>
#include <iomanip>
#include <iterator>
using namespace std;
int main()
{
int n,t;
scanf("%d",&t);
while (t--)
{
scanf("%d",&n);
if (n <= 26)
printf("%c\n", 'A' + n - 1);
else if (n <= 26 * 26 + 26)
{
n -= 27;
int t = n / 26;
printf("%c", 'A' + t);
n = n % 26;
printf("%c\n", 'A' + n);
}
else
{
n -= 27 + 26 * 26;
printf("%c%c%c\n", 'A' + char(n / 26 / 26), 'A' + char((n / 26) % 26), 'A' + char(n % 26));
}
}
return 0;
}
版权声明:转载请注明出处。
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/117143.html原文链接:https://javaforall.cn
边栏推荐
- C # - realize serialization with Marshall class
- 腾讯T2大牛亲自讲解,跳槽薪资翻倍
- 信息系统项目管理师---第八章 项目质量管理
- Druid 数据库连接池 详解
- 手把手教你学会js的原型与原型链,猴子都能看懂的教程
- js实现力扣71题简化路径
- 深度剖析原理,看完这一篇就够了
- Vmware虚拟机无法打开内核设备“\\.\Global\vmx86“的解决方法
- It's enough to read this article to analyze the principle in depth
- Mysql Information Schema 学习(二)--Innodb表
猜你喜欢
In simple terms, interview surprise Edition
Mysql Information Schema 学习(一)--通用表
腾讯T2大牛亲自讲解,跳槽薪资翻倍
蓝桥杯 微生物增殖 C语言
反射及在运用过程中出现的IllegalAccessException异常
【翻译】Linkerd在欧洲和北美的采用率超过了Istio,2021年增长118%。
黑馬--Redis篇
Information System Project Manager - Chapter VIII project quality management
Low CPU load and high loadavg processing method
Spark foundation -scala
随机推荐
map的使用(列表的数据赋值到表单,json逗号隔开显示赋值)
Live broadcast today | the 2022 Hongji ecological partnership conference of "Renji collaboration has come" is ready to go
How to access localhost:8000 by mobile phone
深入分析,Android面试真题解析火爆全网
深度剖析原理,看完这一篇就够了
Tensorflow2.0 self defined training method to solve function coefficients
广州首个数据安全峰会将在白云区开幕
转让malloc()该功能后,发生了什么事内核?附malloc()和free()实现源
Test Li hi
凤凰架构3——事务处理
腾讯T3手把手教你,真的太香了
GCC [7] - compilation checks the declaration of functions, and link checks the definition bugs of functions
swagger2报错Illegal DefaultValue null for parameter type integer
Carte de réflexion + code source + notes + projet, saut d'octets + jd + 360 + tri des questions d'entrevue Netease
激进技术派 vs 项目保守派的微服务架构之争
Druid 数据库连接池 详解
思維導圖+源代碼+筆記+項目,字節跳動+京東+360+網易面試題整理
Low CPU load and high loadavg processing method
[translation] supply chain security project in toto moved to CNCF incubator
面试突击63:MySQL 中如何去重?