我是靠谱客的博主 慈祥啤酒,最近开发中收集的这篇文章主要介绍1027. Colors in Mars (20),觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

考察查询表以及求余分位

#include<iostream>
#include<vector>
char g_CharTable[13] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C'};
void OutPutIntVector(const std::vector<int>& a)
{
int size = (int)a.size();
for(int i = 0; i < size; ++i)
{
printf("%c", g_CharTable[a[i]]);
}
printf("n");
}
void Convert2MarsColor(int r, int g, int b, std::vector<int>& color)
{
color.assign(6, 0);
color[1] = r%13;
color[0] = r/13;
color[3] = g%13;
color[2] = g/13;
color[5] = b%13;
color[4] = b/13;
}
int main()
{
int r, g, b;
while(scanf("%d%d%d", &r, &g, &b) != EOF)
{
std::vector<int> color;
Convert2MarsColor(r, g, b, color);
printf("#");
OutPutIntVector(color);
}
return 0;
}


 

最后

以上就是慈祥啤酒为你收集整理的1027. Colors in Mars (20)的全部内容,希望文章能够帮你解决1027. Colors in Mars (20)所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(56)

评论列表共有 0 条评论

立即
投稿
返回
顶部