mirror of
https://github.com/lWolvesl/leetcode.git
synced 2026-01-13 02:38:37 +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