四位整数每位相加之和
#include <iostream>
using namespace std;
int main()
{
int x, a, b, c, d;
int s = 0;
cout << "请输入一个四位数整数:" ;
cin >> x;
a = x % 10;
b = x / 10 % 10;
c = x / 100 % 10;
d = x / 1000 % 10;
s = a + b + c + d;
cout <<"每位数相加之和为:"<< s << endl;
system ("pause");
return 0;
}