当前位置:网站首页>Wonderful coding [hexadecimal conversion]
Wonderful coding [hexadecimal conversion]
2022-07-06 19:49:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm the king of the whole stack .
Wonderful coding Description If there are no Arabic numerals , We want to figure out how to represent numbers Xiao Ming thinks a way , Like the one below : 1 -> A 2 -> B 3 -> C …. 25 -> Y 26 -> Z 27 -> AA
28 -> AB ….
Now please write a program to complete this conversion
Input The first number entered is a positive integer T, Indicates that there is T Group data . Each group of data is a positive integer n ( n <= 1000)
Output For every positive integer n, Output his corresponding string
Sample Input 3 1 10 27 Sample Output A J AA
Hexadecimal conversion ?
#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;
}
Copyright notice : Reprint please indicate the source .
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/117143.html Link to the original text :https://javaforall.cn
边栏推荐
- MySql必知必会学习
- [translation] supply chain security project in toto moved to CNCF incubator
- 数据的同步为每个站点创建触发器同步表
- 腾讯T2大牛亲自讲解,跳槽薪资翻倍
- 121. 买卖股票的最佳时机
- 潇洒郎: AttributeError: partially initialized module ‘cv2‘ has no attribute ‘gapi_wip_gst_GStreamerPipe
- In simple terms, interview surprise Edition
- 腾讯云数据库公有云市场稳居TOP 2!
- Alibaba data source Druid visual monitoring configuration
- Vmware虚拟机无法打开内核设备“\\.\Global\vmx86“的解决方法
猜你喜欢
Example of applying fonts to flutter
MySQL information schema learning (II) -- InnoDB table
LeetCode_ Double pointer_ Medium_ 61. rotating linked list
腾讯T4架构师,android面试基础
Mysql Information Schema 学习(二)--Innodb表
LeetCode_双指针_中等_61. 旋转链表
【基础架构】Flink/Flink-CDC的部署和配置(MySQL / ES)
redisson bug分析
深入浅出,面试突击版
A5000 vGPU显示模式切换
随机推荐
学习打卡web
350. 两个数组的交集 II
Standardized QCI characteristics
如何自定义动漫头像?这6个免费精品在线卡通头像生成器,看一眼就怦然心动!
10 schemes to ensure interface data security
测试用里hi
【计算情与思】扫地僧、打字员、信息恐慌与奥本海默
js实现力扣71题简化路径
Test Li hi
Mind map + source code + Notes + project, ByteDance + JD +360+ Netease interview question sorting
新一代垃圾回收器—ZGC
【基础架构】Flink/Flink-CDC的部署和配置(MySQL / ES)
DaGAN论文解读
Hudi vs Delta vs Iceberg
beegfs高可用模式探讨
【翻译】数字内幕。KubeCon + CloudNativeCon在2022年欧洲的选择过程
Li Kou 101: symmetric binary tree
腾讯T2大牛亲自讲解,跳槽薪资翻倍
Vscode debug run fluent message: there is no extension for debugging yaml. Should we find yaml extensions in the market?
Learning and Exploration - function anti shake