Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int productOfNumbers(int n) {
- string str_n = to_string(n);
- int result = 1;
- for (char c : str_n) {
- if (c == '-') {
- result *= -1;
- continue;
- }
- result *= (c - '0');
- }
- return result;
- }
- int main() {
- int n;
- cin >> n;
- cout << productOfNumbers(n) << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement