当前位置:网站首页>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
边栏推荐
- 【基础架构】Flink/Flink-CDC的部署和配置(MySQL / ES)
- How to access localhost:8000 by mobile phone
- Introduction to enterprise lean management system
- DaGAN论文解读
- 【翻译】供应链安全项目in-toto移至CNCF孵化器
- Selenium advanced operations
- 小微企业难做账?智能代账小工具快用起来
- 社招面试心得,2022最新Android高频精选面试题分享
- Example of applying fonts to flutter
- 腾讯字节等大厂面试真题汇总,网易架构师深入讲解Android开发
猜你喜欢
How to access localhost:8000 by mobile phone
企业精益管理体系介绍
腾讯T4架构师,android面试基础
Learn to explore - use pseudo elements to clear the high collapse caused by floating elements
【翻译】Linkerd在欧洲和北美的采用率超过了Istio,2021年增长118%。
[infrastructure] deployment and configuration of Flink / Flink CDC (MySQL / es)
Mysql Information Schema 学习(一)--通用表
ZABBIX proxy server and ZABBIX SNMP monitoring
Cesium 点击绘制圆形(动态绘制圆形)
Vmware虚拟机无法打开内核设备“\\.\Global\vmx86“的解决方法
随机推荐
Mysql Information Schema 學習(一)--通用錶
思維導圖+源代碼+筆記+項目,字節跳動+京東+360+網易面試題整理
Tencent Android interview must ask, 10 years of Android development experience
Carte de réflexion + code source + notes + projet, saut d'octets + jd + 360 + tri des questions d'entrevue Netease
Introduction to enterprise lean management system
力扣101题:对称二叉树
Understand yolov1 Part II non maximum suppression (NMS) in prediction stage
Test Li hi
企业精益管理体系介绍
深度剖析原理,看完这一篇就够了
LeetCode_双指针_中等_61. 旋转链表
Phoenix Architecture 2 - accessing remote services
Classic 100 questions of algorithm interview, the latest career planning of Android programmers
如何自定义动漫头像?这6个免费精品在线卡通头像生成器,看一眼就怦然心动!
Mind map + source code + Notes + project, ByteDance + JD +360+ Netease interview question sorting
A5000 vGPU显示模式切换
Chic Lang: attributeerror: partially initialized module 'CV2' has no attribute 'GAPI_ wip_ gst_ GStreamerPipe
Analysis of rainwater connection
Simple application of VBA script in Excel
[translation] Digital insider. Selection process of kubecon + cloudnativecon in Europe in 2022