Advertisement
ahmed_aly

C++ solution for problem A

Apr 13th, 2011
6,890
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.77 KB | None | 0 0
  1. #include <cstring>
  2. #include <map>
  3. #include <deque>
  4. #include <queue>
  5. #include <stack>
  6. #include <sstream>
  7. #include <iostream>
  8. #include <iomanip>
  9. #include <cstdio>
  10. #include <cmath>
  11. #include <cstdlib>
  12. #include <ctime>
  13. #include <algorithm>
  14. #include <vector>
  15. #include <set>
  16. #include <complex>
  17. #include <list>
  18. #include <climits>
  19. #include <cctype>
  20.  
  21. using namespace std;
  22.  
  23. int removeZeros(int num) {
  24.     int ret = 0;
  25.     int ten = 1;
  26.     while (num) {
  27.         int dig = num % 10;
  28.         num /= 10;
  29.         if (dig) {
  30.             ret += dig * ten;
  31.             ten *= 10;
  32.         }
  33.     }
  34.     return ret;
  35. }
  36.  
  37. int main() {
  38.     int a, b, c;
  39.     cin >> a >> b;
  40.     c = a + b;
  41.     a = removeZeros(a);
  42.     b = removeZeros(b);
  43.     c = removeZeros(c);
  44.     if (a + b == c)
  45.         cout << "YES" << endl;
  46.     else
  47.         cout << "NO" << endl;
  48.     return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement