当前位置:网站首页>精彩编码 【进制转换】
精彩编码 【进制转换】
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
边栏推荐
- 接雨水问题解析
- Tencent Android interview must ask, 10 years of Android development experience
- 零基础入门PolarDB-X:搭建高可用系统并联动数据大屏
- Systematic and detailed explanation of redis operation hash type data (with source code analysis and test results)
- 关于图像的读取及处理等
- It's enough to read this article to analyze the principle in depth
- Learning and Exploration - function anti shake
- 腾讯T3大牛手把手教你,大厂内部资料
- Configuration and simple usage of the EXE backdoor generation tool quasar
- C # - realize serialization with Marshall class
猜你喜欢
Microservice architecture debate between radical technologists vs Project conservatives
Live broadcast today | the 2022 Hongji ecological partnership conference of "Renji collaboration has come" is ready to go
深度剖析原理,看完这一篇就够了
[translation] linkerd's adoption rate in Europe and North America exceeded istio, with an increase of 118% in 2021.
如何自定义动漫头像?这6个免费精品在线卡通头像生成器,看一眼就怦然心动!
Cereals Mall - Distributed Advanced p129~p339 (end)
今日直播 | “人玑协同 未来已来”2022弘玑生态伙伴大会蓄势待发
Swiftui game source code Encyclopedia of Snake game based on geometryreader and preference
LeetCode_双指针_中等_61. 旋转链表
CPU负载很低,loadavg很高处理方法
随机推荐
Hudi vs Delta vs Iceberg
Use of deg2rad and rad2deg functions in MATLAB
121. 买卖股票的最佳时机
思維導圖+源代碼+筆記+項目,字節跳動+京東+360+網易面試題整理
CF960G - Bandit Blues(第一类斯特林数+OGF)
Blue Bridge Cup microbial proliferation C language
How to access localhost:8000 by mobile phone
信息系统项目管理师---第八章 项目质量管理
深度剖析原理,看完这一篇就够了
A popular explanation will help you get started
GCC [7] - compilation checks the declaration of functions, and link checks the definition bugs of functions
Lick the dog until the last one has nothing (simple DP)
Druid 数据库连接池 详解
《数字经济全景白皮书》保险数字化篇 重磅发布
今日直播 | “人玑协同 未来已来”2022弘玑生态伙伴大会蓄势待发
蓝桥杯 微生物增殖 C语言
Microservice architecture debate between radical technologists vs Project conservatives
Live broadcast today | the 2022 Hongji ecological partnership conference of "Renji collaboration has come" is ready to go
Social recruitment interview experience, 2022 latest Android high-frequency selected interview questions sharing
【pytorch】yolov5 训练自己的数据集