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;
} 

猜你喜欢

转载自www.cnblogs.com/i-love/p/11508225.html