#include <stdio.h> #include <iostream> #include <stdlib.h> #include <math.h> #include <string.h> using namespace std; int main() { char p[1024]; cin>>p; int len = strlen(p); int i,j; unsigned val; long long sum =0; int k = 0; for(i = len-1; i>=0; i--) { for(j = 0; j<8; j++) { val = p[i]>>j; val&=0x01; sum = sum +val*pow(2,k); k++; } } cout<<sum<<endl; return 0; }
时间: 2024-11-14 06:33:02