【PAT甲级】1027 Colors in Mars (20 分)
2024-09-06 23:41:51
题意:
输入三个范围为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 ;
}
最新文章
- C#-WebForm-简单控件
- ";Java 反序列化";过程远程命令执行漏洞
- ASP.NET中的KRE是什么?
- Redis优化经验
- netty 粘包问题处理
- 【BZOJ 1007】 [HNOI2008]水平可见直线
- FormsAuthentication 登录兼容 IE11 保存cookie
- oracle sys sysman system 介绍
- 每天学点管理学知识——情绪ABC理论
- mac 环境下使用virtual box 虚拟机(win7)与主机之间互相ping通
- [C++] 获取IE代理server的账号password
- referencedColumnName
- SpringMVC入门就这么简单
- spring-oauth-server实践:使用授权方式四:client_credentials 模式的客户端和服务端交互
- IntelliJ IDEA 2016.2 配置Tomcat 运行Web项目
- zigbee 安全通信加密链接密钥
- web自动化测试---css方式定位页面元素
- SQL alwayson 辅助接点查询统计信息“丢失”导致查询失败
- 记录一个elasticsearch 的索引templates
- PHP微信支付开发
热门文章
- java中Integer面试的坑
- i.MX RT1010之FlexIO模拟SSI外设
- Github Pull Request的提出与采纳
- laravel执行数据库迁移的过程中出现Illuminate\Database\QueryException : SQLSTATE[HY000] [2002] Operation timed out (SQL: select * from information_schema.tables where table_schema = shop and table_name = migrations
- 反混淆 de4dot
- STM32F030 启用内部晶振并配置系统时钟为48M
- CSS选择器效率问题
- IIS-反向代理简介
- php substr的一些用法
- 提高Scrapy爬取效率