其他分享
首页 > 其他分享> > 1281. Subtract the Product and Sum of Digits of an Integer

1281. Subtract the Product and Sum of Digits of an Integer

作者:互联网

class Solution {
public:
    int subtractProductAndSum(int n) {
        int sum=0;
        int multiple=1;
        while(n!=0){
            sum += n%10;
            multiple *= n%10;
            n = n/10;
        }
        //cout<<sum<<endl;
        //cout<<multiple<<endl;
        
        return multiple-sum;
    }
};
zeroQiaoba 发布了361 篇原创文章 · 获赞 18 · 访问量 15万+ 私信 关注

标签:Digits,10,Product,1281,int,sum,n%,文章,multiple
来源: https://blog.csdn.net/zeroQiaoba/article/details/104587843