【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 ...
随机推荐
- mysql设置定时任务(对于中控心跳包的实现有意义)
转载:https://www.cnblogs.com/laowu-blog/p/5073665.html 目前用途:因为 脚本正常开关会给中控发送消息 但是万一脚本被强制关闭 没有触发脚本关闭事件就无 ...
- Java面向对象编程 -6.4
二维数组 数组的定义格式 数组的动态初始化:初始化之后数组中的每一个元素的保存的内容为其对应数据类型的默认值 声明并初始化数组: 数据类型 数组名称 [][] = new 数据类型[行个数][列个数] ...
- 炸鱼w咕咕咕
退役选手又回来了w + 将近一个月莫有学OI变得十分笨拙 + 洛谷打卡从300+ 变为 10 + 冬令营加油(虽然我会崩 + 省选加油 (虽然我进不去
- 消息队列(二)--- RocketMQ-NameServer阅读
概述 所有broker在启动的时候都会向NameServer进行注册,对它进行发送心跳包. 源码阅读 我们先从 NamesrvStartup这个类分析 public static void mai ...
- 图片识别OCR:
使用Python制作一个简易的OCR图片文字识别工具:键盘上的PrtScr按键+画图工具+百度AI图片识别(账户,调用接口)+python 常见的OCR工具: 1. Microsoft Onenote ...
- 【MySQL】表的操作
" 目录 #. 表操作 1. 创建数据库 2. 进入指定库 3. 创建表 4. 添加记录 5. 查询表的数据和结构 /. 查指定表中的存储数据 /. 查指定表的结构 6. 复制表 /. 即复 ...
- P1579
AC: #include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for(int i = a; i < b ...
- C语言:判断t所指字符串中的字母是否由连续递增字母组成。-判断一个输入的任何整数n,是否等于某个连续正整数序列之和。-将一副扑克牌编号为1到54,以某种方式洗牌,这种方式是将这副牌分成两半,然后将他们交叉,并始终保持编号1的牌在最上方。
//判断t所指字符串中的字母是否由连续递增字母组成. #include <stdio.h> #include <string.h> void NONO(); int fun( ...
- unittest如何制作测试套件Testsuite 按method,class ,module,按命令行执行unittest
cmd 执行unittest case : python -m unitest test.py test2.py python -m unittest testfile.testclass.tes ...
- 2020年python学习进阶方向
相信很多友人在学习python过程都会遇到很多 虽然python入门很容易 但是难免会遇到瓶颈 遇到问题没人交流 很难提升 对此 给你们简单指点学习方向 1.认识python linux基本 ...