标签:
#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; }
标签:
原文地址:http://www.cnblogs.com/wystan/p/4555640.html