当前位置:网站首页>精彩编码 【进制转换】
精彩编码 【进制转换】
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
边栏推荐
- Tensorflow2.0 self defined training method to solve function coefficients
- 学习探索-使用伪元素清除浮动元素造成的高度坍塌
- JDBC details
- 腾讯T3大牛手把手教你,大厂内部资料
- 潇洒郎: AttributeError: partially initialized module ‘cv2‘ has no attribute ‘gapi_wip_gst_GStreamerPipe
- Social recruitment interview experience, 2022 latest Android high-frequency selected interview questions sharing
- 社招面试心得,2022最新Android高频精选面试题分享
- Spark foundation -scala
- Learning and Exploration - function anti shake
- Druid 数据库连接池 详解
猜你喜欢
Cereals Mall - Distributed Advanced p129~p339 (end)
Leetcode 30. Concatenate substrings of all words
LeetCode_双指针_中等_61. 旋转链表
Pay attention to the partners on the recruitment website of fishing! The monitoring system may have set you as "high risk of leaving"
Blue Bridge Cup microbial proliferation C language
spark基础-scala
The "white paper on the panorama of the digital economy" has been released with great emphasis on the digitalization of insurance
在解决了 2961 个用户反馈后,我做出了这样的改变...
Chic Lang: attributeerror: partially initialized module 'CV2' has no attribute 'GAPI_ wip_ gst_ GStreamerPipe
Interpretation of Dagan paper
随机推荐
颜色(color)转换为三刺激值(r/g/b)(干股)
Using clip path to draw irregular graphics
Cereals Mall - Distributed Advanced p129~p339 (end)
Alibaba data source Druid visual monitoring configuration
信息系统项目管理师---第八章 项目质量管理
手把手教你学会js的原型与原型链,猴子都能看懂的教程
10 schemes to ensure interface data security
利用 clip-path 绘制不规则的图形
Tensorflow2.0 self defined training method to solve function coefficients
POJ 3207 Ikki&#39;s Story IV – Panda&#39;s Trick (2-SAT)
usb host 驱动 - UVC 掉包
redisson bug分析
Tencent Android interview must ask, 10 years of Android development experience
凤凰架构2——访问远程服务
腾讯Android面试必问,10年Android开发经验
黑馬--Redis篇
理解 YOLOV1 第二篇 预测阶段 非极大值抑制(NMS)
Pay attention to the partners on the recruitment website of fishing! The monitoring system may have set you as "high risk of leaving"
企业精益管理体系介绍
Finally, there is no need to change a line of code! Shardingsphere native driver comes out