当前位置:网站首页>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
边栏推荐
- LeetCode_ Gray code_ Medium_ 89. Gray code
- Logstash expressway entrance
- 深度剖析原理,看完这一篇就够了
- Cf960g - bandit Blues (type I Stirling number +ogf)
- Mind map + source code + Notes + project, ByteDance + JD +360+ Netease interview question sorting
- 【翻译】数字内幕。KubeCon + CloudNativeCon在2022年欧洲的选择过程
- Interpretation of Dagan paper
- POJ3617 Best Cow Line 馋
- 理解 YOLOV1 第二篇 预测阶段 非极大值抑制(NMS)
- Tensorflow2.0 self defined training method to solve function coefficients
猜你喜欢
腾讯T2大牛亲自讲解,跳槽薪资翻倍
Low CPU load and high loadavg processing method
It's enough to read this article to analyze the principle in depth
Mysql Information Schema 學習(一)--通用錶
Spark foundation -scala
Chic Lang: attributeerror: partially initialized module 'CV2' has no attribute 'GAPI_ wip_ gst_ GStreamerPipe
LeetCode_ Double pointer_ Medium_ 61. rotating linked list
腾讯T3大牛手把手教你,大厂内部资料
[play with Linux] [docker] MySQL installation and configuration
Vscode debug run fluent message: there is no extension for debugging yaml. Should we find yaml extensions in the market?
随机推荐
Spark foundation -scala
Application of clock wheel in RPC
Phoenix Architecture 2 - accessing remote services
思維導圖+源代碼+筆記+項目,字節跳動+京東+360+網易面試題整理
LeetCode_ Gray code_ Medium_ 89. Gray code
LeetCode_格雷编码_中等_89.格雷编码
测试用里hi
技术分享 | 抓包分析 TCP 协议
Mysql Information Schema 学习(一)--通用表
Blue Bridge Cup microbial proliferation C language
Understand yolov1 Part II non maximum suppression (NMS) in prediction stage
腾讯字节等大厂面试真题汇总,网易架构师深入讲解Android开发
PHP与EXCEL PHPExcel
From spark csc. csr_ Matrix generate adjacency matrix
In simple terms, interview surprise Edition
DOM operation
【基础架构】Flink/Flink-CDC的部署和配置(MySQL / ES)
1805. 字符串中不同整数的数目
系统性详解Redis操作Hash类型数据(带源码分析及测试结果)
350. 两个数组的交集 II