Translation from binary into decimal numbers in C++

后端 未结 3 1830
轻奢々
轻奢々 2021-01-26 19:30

I tried to build a function that calculates a binary number stored in a string into a decimal number stored in a long long. I\'m thinking that my code should work b

3条回答
  •  一整个雨季
    2021-01-26 19:37

    c++ way

    #include 
    #include 
    #include 
    
    
    using namespace std;
    int main() {
        std::string stringNumber = "101110111";   
        long long result = 0;
    
        uint string_length = stringNumber.length();
    
        for(int i = 0; i 

提交回复
热议问题