Advertisement
STANAANDREY

covert MET2

Jul 1st, 2020
1,173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.29 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int convertToB10(const char s[])
  5. {
  6.     int ans = 0;
  7.     for (int i = 0; s[i]; i++)
  8.         ans = ans * 2 + s[i] - '0';
  9.     return ans;
  10. }
  11.  
  12. int main()
  13. {
  14.     string s;
  15.     cin >> s;
  16.     cerr << convertToB10(s.c_str());
  17.     return 0;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement