#include <the iostream> #include <the Windows.h> #include < String > the using namespace STD; int main ( void ) { String STR; int P = . 1 ; // record the current binary weight int S = 0 ; COUT << " enter a binary number: " ; CIN >> STR; for ( int I = str.length () - . 1 ; I> = 0 ; i-- ) { int X STR = [I] - ' 0'; // '0' - '0' = 0 '1' - '0' = 1 s += x * p; p *= 2; // p = p * 2 } cout << s << endl; system("pause"); return 0; }