#includeusing namespace std;int sumAll(int x){ int ret=0; while(x){ ret+=x%10; x/=10; } return ret;}int main(){ int d; printf("请输入需要计算的整数:"); scanf("%d",&d); printf("各位之和是 %d\n",sumAll(d)); return 0;}