当前位置:网站首页>精彩编码 【进制转换】
精彩编码 【进制转换】
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
边栏推荐
- Mind map + source code + Notes + project, ByteDance + JD +360+ Netease interview question sorting
- [玩转Linux] [Docker] MySQL安装和配置
- Elastic search indexes are often deleted [closed] - elastic search indexes gets deleted frequently [closed]
- Application of clock wheel in RPC
- 信息系统项目管理师---第八章 项目质量管理
- How to access localhost:8000 by mobile phone
- Cereals Mall - Distributed Advanced p129~p339 (end)
- Low CPU load and high loadavg processing method
- Alibaba data source Druid visual monitoring configuration
- Vmware虚拟机无法打开内核设备“\\.\Global\vmx86“的解决方法
猜你喜欢

今日直播 | “人玑协同 未来已来”2022弘玑生态伙伴大会蓄势待发
腾讯T2大牛亲自讲解,跳槽薪资翻倍

Hudi vs Delta vs Iceberg

Mind map + source code + Notes + project, ByteDance + JD +360+ Netease interview question sorting

反射及在运用过程中出现的IllegalAccessException异常

A popular explanation will help you get started
![[play with Linux] [docker] MySQL installation and configuration](/img/04/6253ef9fdf7d2242b42b4c7fb2c607.png)
[play with Linux] [docker] MySQL installation and configuration

《数字经济全景白皮书》保险数字化篇 重磅发布

深度剖析原理,看完这一篇就够了

Chic Lang: attributeerror: partially initialized module 'CV2' has no attribute 'GAPI_ wip_ gst_ GStreamerPipe
随机推荐
350. Intersection of two arrays II
反射及在运用过程中出现的IllegalAccessException异常
JDBC details
潇洒郎: AttributeError: partially initialized module ‘cv2‘ has no attribute ‘gapi_wip_gst_GStreamerPipe
The "white paper on the panorama of the digital economy" has been released with great emphasis on the digitalization of insurance
Unbalance balance (dynamic programming, DP)
Li Kou 101: symmetric binary tree
理解 YOLOV1 第二篇 预测阶段 非极大值抑制(NMS)
LeetCode_双指针_中等_61. 旋转链表
腾讯T2大牛亲自讲解,跳槽薪资翻倍
【翻译】数字内幕。KubeCon + CloudNativeCon在2022年欧洲的选择过程
Elastic search indexes are often deleted [closed] - elastic search indexes gets deleted frequently [closed]
Spark foundation -scala
Use of deg2rad and rad2deg functions in MATLAB
zabbix 代理服务器 与 zabbix-snmp 监控
121. 买卖股票的最佳时机
Swagger2 reports an error illegal DefaultValue null for parameter type integer
Alibaba data source Druid visual monitoring configuration
Phoenix Architecture 3 - transaction processing
Interpretation of Dagan paper