#include
using namespace std;
//计算x的n次方
double power (double x, int n);
int main()
{
int value = 0;
cout << "Enter an 8 bit binary number \n ";
for (int i = 7; i >= 0; i--)
{
char ch;
cin >> ch;
if (ch == '1')
value += static_cast(power(2, i));
}
cout<<"output:\n";
cout << "Decimal value is " << value << endl;
return 0;
}
/**********begin****************/
double power (double x, int n)
{
int i;
double d=1;
for(i=0;id *= x ;
return d;
}
/*********end****************/