Advertisement
Guest User

fuckingpoulouks

a guest
Jul 3rd, 2015
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     string input;
  8.     cin >> input;
  9.  
  10.     int length = input.length();
  11.     if(length != 8)
  12.     {
  13.         cout << "error";
  14.  
  15.     }
  16.     int sum = 0;
  17.     int j = 128;
  18.  
  19.     for(int i = 0; i >length; i++)
  20.     {
  21.         if(input.at(i) == 1)
  22.         {
  23.             sum = sum + j;
  24.  
  25.         }
  26.         j = j /2;
  27.     }
  28.     cout << sum << endl;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement