#include <stdio.h>
int main()
{
int one,two,three,four,x4,total;
printf("请输入一个四位正整数:");
scanf("%d",&x4);
one = x4 / 1000;
two = x4 % 1000 / 100;
three = x4 % 1000 % 100 / 10;
four = x4 % 1000 % 100 % 10;
total = one + two + three + four;
printf("\n千位数字是:%d\n",one);
printf("百位数字是:%d\n",two);
printf("十位数字是:%d\n",three);
printf("个位数字是:%d\n",four);
printf("\n输入的四位数每位相加得:%d\n",total);
return 0;
}
温馨提示:答案为网友推荐,仅供参考