Gireada

SOC 2

Mar 3rd, 2017
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.37 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3. #include <string.h>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     int i, r;
  10.     char n[9];
  11.     cin>>n;
  12.     i = strlen(n)-1;
  13.     r = n[i] - '0';
  14.     i--;
  15.     while(i > 0)
  16.     {
  17.         if(n[i] == '0')
  18.             r = r*2+0;
  19.         if(n[i] == '1')
  20.             r = r*2+1;
  21.         i--;
  22.     }
  23.     cout<<r;
  24.     return 0;
  25. }
Add Comment
Please, Sign In to add comment