#include
int main()
{int x,a,b,c,d,s;
scanf("%d",&x);
a=x/1000;
b=x/100%10;
c=x/10%10;
d=x%10;
s=a+b+c+d;
printf("%d %d %d %d\n%d",a,b,c,d,s);
return 0;
}
#include "stdio.h"
int main(int argc,char *argv[]){
int n,s,t;
printf("Please enter n(int 999if(scanf("%d",&n)!=1 || n<1000 || n>9999){
printf("Input error, exit...\n");
return 0;
}
for(s=0;n;n/=10){
printf("%d ",t=n%10);
s+=t;
}
printf("\nThe sum of them is %d\n",s);
return 0;
}
运行样例: