csp 201512-1 数位之和

这道题说明了int可以表示10^10以下的数,那么大中小的那个数,运算中出的问题????好懵呀

#include<iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    
    int sum=0;
    while(n){
        sum+=n%10;
        n=n/10;
    }
    cout<<sum<<endl;
    return 0;
} 

 

posted @ 2019-09-11 19:31  祺祥  阅读(153)  评论(0编辑  收藏  举报