【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 ...
随机推荐
- pycharm中的搜索快捷键
- dfs序与求子树子节点(染了色)的个数
https://blog.csdn.net/hpu2022/article/details/81910490 https://blog.csdn.net/qq_39670434/article/det ...
- 一周搞定模拟电路P2_二极管介绍_记录
1 稳压二极管 1.1 稳压二极管伏安特性曲线 ΔIz 这一段为能够达到比较好的稳压效果的稳压电流. 1.2 两种连接方法的比较 2 整流二极管 2.1 特点 用于把交流电变成脉动直流电 3 开关二极 ...
- java_设计模式_装饰设计模式
package IO; /* * 装饰设计模式 模拟咖啡 * 1.抽象组件:需要装饰的抽象对象(接口或抽象父类) * 2.具体组件:需要装饰的对象 * 3.抽像装饰类:包含了对抽象组件的引用以及装饰着 ...
- Java补强转
/* 对于byte/short/char三种类型来说,如果右侧赋值的数值没有超过范围, 那么javac编译器将会自动隐含地为我们补上一个(byte)(short)(char). 1. 如果没有超过左侧 ...
- 【C语言】无参函数调用实例
#include<stdio.h> void hello() { printf("年轻人,加油!"); } int main() { hello(); ; }
- 吴裕雄--天生自然Numpy库学习笔记:NumPy 排序、条件刷选函数
numpy.sort() 函数返回输入数组的排序副本.函数格式如下: numpy.sort(a, axis, kind, order) 参数说明: a: 要排序的数组 axis: 沿着它排序数组的轴, ...
- 吴裕雄 PYTHON 神经网络——TENSORFLOW 正则化
import tensorflow as tf import matplotlib.pyplot as plt import numpy as np data = [] label = [] np.r ...
- linux(centos6.10)下去掉mysql的强密码验证
vim /etc/my.cnf shift + G 光标移到最下方: o 进入插入模式,同时换行: 添加一行语句: validate_password=OFF 保存退出. servi ...
- 【PAT甲级】1039 Course List for Student (25 分)(vector嵌套于map,段错误原因未知)
题意: 输入两个正整数N和K(N<=40000,K<=2500),分别为学生和课程的数量.接下来输入K门课的信息,先输入每门课的ID再输入有多少学生选了这门课,接下来输入学生们的ID.最后 ...