mirror of
https://git.wolves.top/wolves/leetcode.git
synced 2025-11-05 01:36:32 +08:00
14 lines
275 B
C++
14 lines
275 B
C++
class Q1281 {
|
|
public:
|
|
int subtractProductAndSum(int n) {
|
|
int plus = 0;
|
|
int mult = 1;
|
|
while (n) {
|
|
int quo = n % 10;
|
|
n = n / 10;
|
|
plus += quo;
|
|
mult *= quo;
|
|
}
|
|
return mult - plus;
|
|
}
|
|
}; |