You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
463 B

2 years ago
#include<iostream>
#include<conio.h>
using namespace std;
//<2F><><EFBFBD><EFBFBD> x<><78>n<EFBFBD>η<EFBFBD>
double power (int x, int n)
{
int result=1;
for(int i=0;i<n;i++)
{
result=result*x;
}
return result;
}
int main()
{
int all=0;
string p = "1011";
for( int i=0;i<p.length();i++)
{
if(p[p.length()-i-1]=='1')
{
all=all+power(2,i);
}
}
cout<<all<<endl;
getch();
return 0;
}