Files
python/TangDou/LuoGuBook/L19_3.cpp

18 lines
309 B
C++
Raw Normal View History

2025-08-30 18:35:01 +08:00
#include <bits/stdc++.h>
using namespace std;
int main() {
string s = "10101101";
int n = 0;
int k = 0;
for (int i = s.size() - 1; i >= 0; i--) {
int x = s[i] - '0';
n += x * (1 << k);// x* pow(2,n)
k++;
}
cout << n << endl;
return 0;
}