1. #include <iostream>
  2. using namespace std;
  3. int main(){
  4. int n,ge,shi,bai,he;
  5. cout << "请输入一个三位数:";
  6. cin >> n;
  7. ge=n%10;
  8. shi=(n/10)%10;
  9. bai=n/100;
  10. he=ge+shi+bai;
  11. cout<<"各个位数之和是:"<<he<<endl;
  12. return 0;
  13. }