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;
    }
};
1281. Subtract the Product and Sum of Digits of an Integer1281. Subtract the Product and Sum of Digits of an Integer zeroQiaoba 发布了361 篇原创文章 · 获赞 18 · 访问量 15万+ 私信 关注
上一篇:0055 html5新增表单属性:required、placeholder、autofocus、autocomplete、multiple


下一篇:基于Windows下处理Java错误:编码GBK的不可映射字符的解决方案