/*

made by hahahia

main.cpp */


#include <iostream>

#include <vector>

#include <cstdlib>

#include <cmath>

#include <iterator>

#include <algorithm>

#include <string>

 

using namespace std;

 

int main(){

        int result = 0;

        string str;

        cin >> str;

        int e=1;

        for(int i=str.length()-1; i>=0; i--)

        {

               for(int j=0; j<str.length()-i-1; j++)

                       e*=2;

               if(str[i] == '1')

                       result += e;

               e=1;

        }

        cout << result << endl;

        return 0;

}






출력 결과


0011

3


1001

9


1100

12

신고
  1. c언어초보 2014.02.07 19:07 신고

    이건 2진수를 10진수로 변환 하는것 같은데요.

+ Recent posts

티스토리 툴바