首页 > 其他分享 >PAT Advanced 1027 Colors in Mars(20)

PAT Advanced 1027 Colors in Mars(20)

时间:2022-08-21 00:33:49浏览次数:62  
标签:digits digit 20 color 1027 Colors Mars output PAT

题目描述:

People in Mars represent the colors in their computers in a similar way as the Earth people. That is, a color is represented by a 6-digit number, where the first 2 digits are for Red, the middle 2 digits for Green, and the last 2 digits for Blue. The only difference is that they use radix 13 (0-9 and A-C) instead of 16. Now given a color in three decimal numbers (each between 0 and 168), you are supposed to output their Mars RGB values.

Input Specification:

Each input file contains one test case which occupies a line containing the three decimal color values.

Output Specification:

For each test case you should output the Mars RGB value in the following format: first output #, then followed by a 6-digit number where all the English characters must be upper-cased. If a single color is only 1-digit long, you must print a 0 to its left.

Sample Input:

15 43 71

Sample Output:

#123456

算法描述:进制转换 模拟

题目大意:

输入三个十进制数,转换十三进制输出

#include<iostream>
using namespace std;

char str[14]="0123456789ABC";
int main()
{
    cout << "#";
    for(int i = 0; i < 3 ; i++)
    {
        int num;
        cin >> num;
        cout << str[num / 13] << str[num % 13];
    }
    return 0;
}

标签:digits,digit,20,color,1027,Colors,Mars,output,PAT
From: https://www.cnblogs.com/yztozju/p/16609160.html

相关文章

  • 2022.8.20 线程通信问题与线程池
    7、线程通信问题生产者消费者模式的问题应用场景︰生产者和消费者问题假设仓库中只能存放一件产品,生产者将生产出来的产品放入仓库﹐消费者将仓库中产品取走消费﹒如果仓......
  • 2022.8.20 线程状态
    5、线程状态1.线程五大状态: 2.线程方法2.1停止线程案例packagecom.xing.demo03;/***测试stop*1.建议线程正常停止-->利用次数,不建议死循环*2.建......
  • 2022.8.20 线程同步
    6、线程同步1.介绍多个线程操作同一个资源     由于同一进程的多个线程共享同一块存储空间,在带来方便的同时,也带来了访问冲突问题,为了保证数据在方法中......
  • 《GB27898.4-2011》PDF下载
    《GB27898.4-2011固定消防给水设备第4部分:消防气体顶压给水设备》PDF下载《GB27898.4-2011》简介GB27898的本部分规定了消防气体顶压给水设备的术语和定义、分类、要......
  • 《GB27898.2-2011》PDF下载
    《GB27898.2-2011固定消防给水设备第2部分:消防自动恒压给水设备》PDF下载《GB27898.2-2011》简介GB27898的本部分规定了消防自动恒压给水设备的术语和定义、分类、要......
  • 2022.8.20 线程简介与三种创建方式
    1、线程简介1.多任务   现实中太多这样同时做多件事情的例子了,看起来是多个任务都在做,其实本质上我们的大脑在同一时间依旧只做了一件事情。2.多线程   ......
  • 2022.8.20 Lamda表达式与静态代理
    3、Lamda表达式λ希腊字母表中排序第十一位的字母,英语名称为Lambda避免匿名内部类定义过多其实质属于函数式编程的概念去掉了一堆没有意义的代码,只留下核心......
  • 《GB27898.3-2011》PDF下载
    《GB27898.3-2011固定消防给水设备第3部分:消防增压稳压给水设备》PDF下载《GB27898.3-2011》简介GB27898的本部分规定了消防增压稳压给水设备的术语和定义、分类、要......
  • 《GB27898.1-2011》PDF下载
    《GB27898.1-2011固定消防给水设备第1部分:消防气压给水设备》PDF下载《GB27898.1-2011》简介GB27898的本部分规定了消防气压给水设备的术语和定义、分类、要求、试验......
  • 《GB18467-2011》PDF下载
    《GB18467-2011献血者健康检查要求》PDF下载《GB18467-2011》简介本标准规定了一般血站献血者健康检查的项目和要求;本标准适用于一般血站对献血者的健康检查;不适用于......