Search
 
SCRIPT & CODE EXAMPLE
 

CPP

C++ convert vector of digits into integer

// Convert vector of digits to integer
long long vector_to_int(vector<int> num) { 
    long long n = 0;
    int N = num.size();
    for (int i = 0; i < N; i++) {
        n += num[i]*pow(10, N-i-1);
    }
    return n;
}
Comment

C++ convert integer to digits, as vector

// Convert integer to vector of digits
vector<int> int_to_vector(long long n) { 
    vector<int> vec;
    while (n != 0) {
        vec.push_back(n%10);
        n /= 10;
    }
    reverse(vec.begin(), vec.end());
    return vec;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: opencv c++ hello world 
Cpp :: optimized bubble sort 
Cpp :: how to check is some number is divisible by 3 in c++ 
Cpp :: c++ evaluate expression 
Cpp :: calling struct to a struct c++ 
Cpp :: read file into vector 
Cpp :: remove first element from vector c++ 
Cpp :: elixir update map 
Cpp :: c++ program to take input from user 
Cpp :: c++ iterate over vector 
Cpp :: C++ do...while Loop 
Cpp :: chrono start time in c++ 
Cpp :: how to convert int to std::string 
Cpp :: c++ construnctor 
Cpp :: Rick Astley - Never Gonna Give You Up 
Cpp :: c++ length of char array 
Cpp :: height of bst cpp 
Cpp :: c++ random number within range 
Cpp :: cpp Sieve algorithm 
Cpp :: create file c++ 
Cpp :: all possible permutations of characters in c++ 
Cpp :: the code execution cannot proceed because glew32.dll was not found 
Cpp :: c++ vector size 
Cpp :: how to split a string in c++ 
Cpp :: Pyramid pattren program in C++ 
Cpp :: int to hexadecimal in c++ 
Cpp :: c++ thread incide class 
Cpp :: change colour of output to terminal c++ 
Cpp :: cin getline 
Cpp :: implementing split function in c++ 
ADD CONTENT
Topic
Content
Source link
Name
9+8 =