#include<iostream> #include<string> using namespace std; string s[10] = { "0000","0001","0010","0011","0100","0101","0110","0111","1000","1001" }; string DtoB(int x) { string res; while (x / 10!=0) { res.insert(0, s[x % 10]); x /= 10; } res.insert(0, s[x]); return res; } string BtoD(string x) { string res; int a[4]; for (int i = 0;i < 32;i++) { a[i % 4] = x[i] - '0'; if (i % 4 == 3) { int temp = 8 * a[0] + 4 * a[1] + 2 * a[2] + 1 * a[3]; if (temp >= 10) { res += 'a' + temp % 10; } else { res += temp + '0'; } } } return res; } int main() { int r,x,y; char c; while (cin >> r >> c >> x >> c >> y) { string B = DtoB(r); B[31 - x] = '0'; B.replace(B.begin() + 31 - y, B.begin() + 33 - y, "110"); string D = BtoD(B); cout << D << endl; } } |
Double click to view unformatted code.