给定一个整数n,输出n的各位数字之和。
#include<iostream> using namespace std; int main() { int n,m=0,s=0; cin>>n; do{ m=n%10; s=s+m; n=n/10; }while(n%10!=0||n/10!=0); cout<<s; return 0; }