您的位置:首页 > 其它

PAT (Advanced Level)1027. Colors in Mars (20)

2018-03-04 23:35 423 查看
4000
题目链接
超简单题,代码四舍五入相当于1行,真正上战场能遇到这种题真的是Happy至极。

1027. Colors in Mars (20)

时间限制400 ms
内存限制65536 kB
代码长度限制16000 B
判题程序Standard作者CHEN, Yue
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.InputEach input file contains one test case which occupies a line containing the three decimal color values.OutputFor 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 the left.Sample Input
15 43 71
Sample Output
#123456
//1027. Colors in Mars(20)

#include <iostream>
using namespace std;

int main() {
int a, b, c;
while (cin >> a >> b >> c) {
char d[2], e[2], f[2];
d[0] = (a / 13 < 10 ? a / 13 + '0' : a / 13 - 10 + 'A');
d[1] = (a % 13 < 10 ? a % 13 + '0' : a % 13 - 10 + 'A');
e[0] = (b / 13 < 10 ? b / 13 + '0' : b / 13 - 10 + 'A');
e[1] = (b % 13 < 10 ? b % 13 + '0' : b % 13 - 10 + 'A');
f[0] = (c / 13 < 10 ? c / 13 + '0' : c / 13 - 10 + 'A');
f[1] = (c % 13 < 10 ? c % 13 + '0' : c % 13 - 10 + 'A');
cout << "#" << d[0] << d[1] << e[0] << e[1] << f[0] << f[1] << endl;
}
return 0;
}ps:电脑又卡了。。。。。。关机睡觉!
ps :阻碍我的不是学习动力不足,而是money不足导致的电脑性能不足,攒money升配置
ps:打麻将又输了120,没赢过就,为考研攒人品
ps:Most Importantly,保佑自己顺利进入浙大的复试,顺利考取浙大,圆我纯洁的名校梦!!!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: