1027. Colors in Mars (20)

来源:互联网 发布:密苏里科技大学知乎 编辑:程序博客网 时间:2024/06/06 17:38

#include <iostream>#include <string>using namespace std;const char ch[]={'0','1','2','3','4','5','6','7','8','9','A','B','C'};string DecTo13(int num){  string str;  char temp[3];  if(num==0){  temp[0]='0';  temp[1]='0';  }  else if(num<13){    temp[0]='0';    temp[1]=ch[num];  }  else{    temp[0]=ch[num/13];    temp[1]=ch[num%13];  }  temp[2]='\0';  str=temp;  return str;} int main(){  int r,g,b;  cin>>r>>g>>b;  cout<<'#'<<DecTo13(r)<<DecTo13(g)<<DecTo13(b);  return 0;}


0 0
原创粉丝点击