#include <iostream>
using namespace std;
int main() {
    int n;
    cin>>n;
    int a[10],i=0,len;
    while(n>0){
        a[i]=n%10;
        n=n/10;
        i++;
    }
    len=i;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
    for(int j=0;j<len;j++){
        cout<<a[j]<<" ";
    }
    int sum=0;
    while(len>=0){
        for(int i=0;i<len;i++){
            sum+=a[i];
        }
        len=len-2;
    }
    cout<<"\n"<<sum<<"\n";
    return 0;
}

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: