#include int main(){ int a, sum = 0; printf("请输入4位整数:\n"); scanf("%d", &a); while (a) { sum += a % 10; a /= 10; } printf("各位上数字和为%d\n", sum); return 0;}