二进制转十进制

发布时间 2023-04-12 21:02:30作者: 卖核弹的小女孩~

输入一个八位二进制数,将其转换成十进制。

#include <iostream>
using namespace std;
double power(double x,int n);
int main()
{
double x;
int a;
cin>>x>>a;
power(x,a);
cout<<power(x,a)<<endl;
return 0;
}
double power(double x,int n){
double y=1.0;
while(n--){
y=y*x;
}
return y;
}