当前位置:网站首页>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
边栏推荐
- [translation] micro survey of cloud native observation ability. Prometheus leads the trend, but there are still obstacles to understanding the health of the system
- HDU 1026 Ignatius and the Princess I 迷宫范围内的搜索剪枝问题
- Leetcode 30. 串联所有单词的子串
- js实现力扣71题简化路径
- AddressSanitizer 技术初体验
- Standardized QCI characteristics
- Appx代码签名指南
- Information System Project Manager - Chapter VIII project quality management
- Understand yolov1 Part II non maximum suppression (NMS) in prediction stage
- The "white paper on the panorama of the digital economy" has been released with great emphasis on the digitalization of insurance
猜你喜欢

社招面试心得,2022最新Android高频精选面试题分享
腾讯字节等大厂面试真题汇总,网易架构师深入讲解Android开发

10 schemes to ensure interface data security

【基础架构】Flink/Flink-CDC的部署和配置(MySQL / ES)

Pay attention to the partners on the recruitment website of fishing! The monitoring system may have set you as "high risk of leaving"

Configuration and simple usage of the EXE backdoor generation tool quasar

Carte de réflexion + code source + notes + projet, saut d'octets + jd + 360 + tri des questions d'entrevue Netease

How to access localhost:8000 by mobile phone

MySQL information Schema Learning (i) - - General table

腾讯字节阿里小米京东大厂Offer拿到手软,老师讲的真棒
随机推荐
MySQL information Schema Learning (i) - - General table
颜色(color)转换为三刺激值(r/g/b)(干股)
凤凰架构2——访问远程服务
POJ3617 Best Cow Line 馋
Information System Project Manager - Chapter VIII project quality management
学习探索-无缝轮播图
AsyncHandler
思維導圖+源代碼+筆記+項目,字節跳動+京東+360+網易面試題整理
转让malloc()该功能后,发生了什么事内核?附malloc()和free()实现源
From spark csc. csr_ Matrix generate adjacency matrix
测试用里hi
腾讯T3大牛手把手教你,大厂内部资料
在解决了 2961 个用户反馈后,我做出了这样的改变...
String长度限制?
LeetCode_ Gray code_ Medium_ 89. Gray code
Low CPU load and high loadavg processing method
Cf960g - bandit Blues (type I Stirling number +ogf)
It's enough to read this article to analyze the principle in depth
beegfs高可用模式探讨
leetcode先刷_Maximum Subarray