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 Integer
猜你喜欢
转载自blog.csdn.net/zeroQiaoba/article/details/104587843
今日推荐
周排行