【PAT甲级】1027 Colors in Mars (20 分)
题意:
输入三个范围为0~168的整数,将它们从十三进制转化为十进制然后前缀#输出。
AAAAAccepted code:
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
char ans[][];
int main(){
int a,b,c;
cin>>a>>b>>c;
int cnt=;
while(a){
int x=a%;
if(x==)
ans[][++cnt]='A';
else if(x==)
ans[][++cnt]='B';
else if(x==)
ans[][++cnt]='C';
else
ans[][++cnt]=x+'';
a/=;
}
if(cnt==)
ans[][]='',ans[][]='';
else if(cnt==)
ans[][]='';
cnt=;
while(b){
int x=b%;
if(x==)
ans[][++cnt]='A';
else if(x==)
ans[][++cnt]='B';
else if(x==)
ans[][++cnt]='C';
else
ans[][++cnt]=x+'';
b/=;
}
if(cnt==)
ans[][]='',ans[][]='';
else if(cnt==)
ans[][]='';
cnt=;
while(c){
int x=c%;
if(x==)
ans[][++cnt]='A';
else if(x==)
ans[][++cnt]='B';
else if(x==)
ans[][++cnt]='C';
else
ans[][++cnt]=x+'';
c/=;
}
if(cnt==)
ans[][]='',ans[][]='';
else if(cnt==)
ans[][]='';
cout<<"#"<<ans[][]<<ans[][]<<ans[][]<<ans[][]<<ans[][]<<ans[][];
return ;
}
【PAT甲级】1027 Colors in Mars (20 分)的更多相关文章
- PAT 甲级 1027 Colors in Mars (20 分)(简单,进制转换)
1027 Colors in Mars (20 分) People in Mars represent the colors in their computers in a similar way ...
- PAT Advanced 1027 Colors in Mars (20 分)
People in Mars represent the colors in their computers in a similar way as the Earth people. That is ...
- PAT (Advanced Level) Practice 1027 Colors in Mars (20 分) 凌宸1642
PAT (Advanced Level) Practice 1027 Colors in Mars (20 分) 凌宸1642 题目描述: People in Mars represent the c ...
- PAT 甲级 1027 Colors in Mars (20 分)
1027 Colors in Mars (20 分) People in Mars represent the colors in their computers in a similar way a ...
- PAT甲级——1027 Colors in Mars
1027 Colors in Mars People in Mars represent the colors in their computers in a similar way as the E ...
- PAT (Advanced Level) Practice 1027 Colors in Mars (20 分)
People in Mars represent the colors in their computers in a similar way as the Earth people. That is ...
- PAT 甲级 1027 Colors in Mars
https://pintia.cn/problem-sets/994805342720868352/problems/994805470349344768 People in Mars represe ...
- 1027 Colors in Mars (20 分)
People in Mars represent the colors in their computers in a similar way as the Earth people. That is ...
- PAT甲级:1152 Google Recruitment (20分)
PAT甲级:1152 Google Recruitment (20分) 题干 In July 2004, Google posted on a giant billboard along Highwa ...
随机推荐
- redis持久化2
编程迷思 博客园 首页 联系 订阅 管理 随笔 - 11 文章 - 0 评论 - 318 深入学习Redis(2):持久化 前言 在上一篇文章中,介绍了Redis的内存模型,从这篇文章开始,将依次 ...
- IDEA中编辑HTML格式,不自动缩进问题
在IntelliJ Idea中HTML格式化时,默认<head><body>以及<body>下的标签都不会缩进,这就导致你每次写好html时候格式化的时候所有标签都 ...
- mysql区分大小写问题
- 高级命令之awk
1.提取文件内容 2.提取ip
- CF-----Pillars
. Pillars There are n pillars aligned in a row and numbered from 1 to n. Initially each pillar conta ...
- java 对图片的添加文字描述,以及两张图片合成一张
最近公司一个需要,需要把商品的优惠卷分享链接,生成一个二维码然后和商品主图合成一张,并且在新合成的主图增加商品信息的描述,好了直接看合成后图片的样式 下面我就直接贴代码,首先是Contorller层 ...
- mysql-8.0.18-winx64 环境变量的配置
1. 鼠标右击 此电脑 -->属性 如图:进行步骤 1->2->3 接下来就可以使用命令mysql -u root -p登录mysql了 启动mysql的命令为net ...
- Python中的浅复制、深复制
参考 https://docs.python.org/3/library/copy.html?highlight=copy%20copy#copy.copy https://en.wikipedia. ...
- java.lang.NoClassDefFoundError异常处理
1.异常信息: Caused by: java.lang.NoClassDefFoundError: com/pingan/cfss/monitor/user/controller/UserInfoC ...
- Python 中多进程、多线程、协程
进程: 一个运行的程序(代码)就是一个进程,没有运行的代码叫程序,进程是系统资源分配的最小单位,进程拥有自己独立的内存空间,所以进程间数据不共享.开销大. 线程: 调度执行的最小单位,也叫执行路径,不 ...