这个题就是进制之间的转换,模拟即可。 程序代码: #include<iostream> #include<string> #include<cstdio> using namespace std; string SkewBinary; int main() { int num, len, Carry; //freopen("input.txt", "r", stdin); while(cin>>SkewBinary){ if(SkewBinary[0] == '0') break; num = 0; len = SkewBinary.size() - 1; Carry = 0; for(int i = len; i >= 0; i--){ Carry = (Carry + 1) * 2 - 1; num += Carry * (SkewBinary[i] - '0'); } cout<<num<<endl; } return 0; }