mirror of
https://git.wolves.top/wolves/leetcode.git
synced 2025-11-04 17:26:32 +08:00
init
This commit is contained in:
14
23/08/1281.cpp
Normal file
14
23/08/1281.cpp
Normal file
@@ -0,0 +1,14 @@
|
||||
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;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user