我是靠谱客的博主 慈祥啤酒,这篇文章主要介绍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.内容请搜索靠谱客的其他文章。

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

评论列表共有 0 条评论

立即
投稿
返回
顶部