Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <conio.h>
- #include <string.h>
- using namespace std;
- int main()
- {
- int i, r;
- char n[9];
- cin>>n;
- i = strlen(n)-1;
- r = n[i] - '0';
- i--;
- while(i > 0)
- {
- if(n[i] == '0')
- r = r*2+0;
- if(n[i] == '1')
- r = r*2+1;
- i--;
- }
- cout<<r;
- return 0;
- }
Add Comment
Please, Sign In to add comment