逆序拆分输出(任意整数)

题目描述
输入一个不确定位数的正整数,将它完全拆分,并逆序输出。

输入
一行,包含一个正整数。

输出
一行,包含若干个正整数,依次从最低位到最高位,数字与数字之间用一个空格隔开。

样例输入 Copy
1230

样例输出 Copy
0 3 2 1

输入字符串并逆序输出就行

#include<stdio.h>
#include<string.h>
int main()
{
    char t[150];
    scanf("%s",t);
    for(int j=strlen(t)-1; j>=0; j--)
        printf("%c ",t[j]);
    return 0;
}

c++

#include<iostream>
using namespace std;
int main()
{
    int n;
    cin >> n;
    while(n)
    {
        cout <<n%10<< " ";
        n/=10;
    }
    return 1;
}
#include <iostream>
#include <string>
#include <iterator>
#include <algorithm>

using namespace std;

int main()
{
    string str;
    cin >> str;
    copy(str.rbegin(), str.rend(), ostream_iterator<char>(cout, " "));
    return 0;
}