📜  将 int 转换为 int 数组的程序 c++ 代码示例

📅  最后修改于: 2022-03-11 14:44:56.244000             🧑  作者: Mango

代码示例1
#include 
#include 
using namespace std;

vector  integerToArray(int x)
{
    vector  resultArray;
    while (true)
    {
    resultArray.insert(resultArray.begin(), x%10);
    x /= 10;
    if(x == 0)
        return resultArray;
    }
}

int main()
{
    vector  temp = integerToArray(1234567);
    for (auto const &element : temp)
        cout << element << " " ;
    return 0;
}

//outputs 1 2 3 4 5 6 7