You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
432 B
24 lines
432 B
#include <bits/stdc++.h>
|
|
|
|
using namespace std;
|
|
|
|
int main() {
|
|
const int N = 100;
|
|
int a[N] = {0};
|
|
char s[N];
|
|
cin >> s;
|
|
|
|
//字符串的长度
|
|
int length = strlen(s);
|
|
|
|
for (int i = 0; i < length; ++i) {
|
|
a[i] = s[i] - '0';
|
|
}
|
|
int sum = 0;
|
|
for (int i = 0; i < length; i++) {
|
|
sum += a[i] * pow(2, length - i - 1);
|
|
}
|
|
cout << sum << endl;
|
|
return 0;
|
|
}
|