基本思想:
进制转换经典问题;
关键点:
关于进制处理,需要注意下这个常用操作;
1 #include<iostream> 2 #include<stdlib.h> 3 #include<stdio.h> 4 #include<vector> 5 #include<string> 6 #include<math.h> 7 #include<algorithm> 8 using namespace std; 9 using std::vector; 10 11 string trans(int t) { 12 string s; 13 int a; 14 while (t != 0) { 15 a = t % 13; 16 if (a < 10) { 17 s.push_back(‘0‘ + a); 18 } 19 else { 20 s.push_back(‘A‘ + a - 10); 21 } 22 t /= 13; 23 } 24 while (s.size()<2) 25 s.push_back(‘0‘); 26 reverse(s.begin(), s.end());; 27 return s; 28 } 29 30 int main() { 31 int a, b, c; 32 scanf("%d %d %d", &a, &b, &c); 33 cout << "#" << trans(a) << trans(b) << trans(c); 34 system("pause"); 35 return 0; 36 }
1027 Colors in Mars (20point(s)) Easy only once
原文:https://www.cnblogs.com/songlinxuan/p/12197135.html