当前位置:网站首页>精彩编码 【进制转换】
精彩编码 【进制转换】
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
边栏推荐
- Analysis of rainwater connection
- GCC [7] - compilation checks the declaration of functions, and link checks the definition bugs of functions
- POJ 3207 Ikki&#39;s Story IV – Panda&#39;s Trick (2-SAT)
- USB host driver - UVC swap
- 思维导图+源代码+笔记+项目,字节跳动+京东+360+网易面试题整理
- 算法面试经典100题,Android程序员最新职业规划
- Swagger2 reports an error illegal DefaultValue null for parameter type integer
- Learning and Exploration - function anti shake
- Spark foundation -scala
- Simple application of VBA script in Excel
猜你喜欢
学习探索-使用伪元素清除浮动元素造成的高度坍塌
潇洒郎: AttributeError: partially initialized module ‘cv2‘ has no attribute ‘gapi_wip_gst_GStreamerPipe
In depth analysis, Android interview real problem analysis is popular all over the network
Teach you to learn JS prototype and prototype chain hand in hand, a tutorial that monkeys can understand
Learn to explore - use pseudo elements to clear the high collapse caused by floating elements
ZABBIX proxy server and ZABBIX SNMP monitoring
spark基础-scala
10 schemes to ensure interface data security
手把手教你学会js的原型与原型链,猴子都能看懂的教程
LeetCode_ Double pointer_ Medium_ 61. rotating linked list
随机推荐
【翻译】云原生观察能力微调查。普罗米修斯引领潮流,但要了解系统的健康状况仍有障碍...
面试突击63:MySQL 中如何去重?
MySQL must know and learn
Problems encountered in using RT thread component fish
【翻译】供应链安全项目in-toto移至CNCF孵化器
Reflection and illegalaccessexception exception during application
【pytorch】yolov5 训练自己的数据集
终于可以一行代码也不用改了!ShardingSphere 原生驱动问世
Simple application of VBA script in Excel
MySQL information schema learning (II) -- InnoDB table
Test Li hi
map的使用(列表的数据赋值到表单,json逗号隔开显示赋值)
[pytorch] yolov5 train your own data set
Interpretation of Dagan paper
redisson bug分析
Is not a drawable (color or path): the vector graph downloaded externally cannot be called when it is put into mipmap, and the calling error program crashes
short i =1; i=i+1与short i=1; i+=1的区别
LeetCode_ Double pointer_ Medium_ 61. rotating linked list
PMP practice once a day | don't get lost in the exam -7.6
学习探索-使用伪元素清除浮动元素造成的高度坍塌