avr39ripe

delNum

Jun 19th, 2020
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.43 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. int main()
  4. {
  5.     int num{ 0 };
  6.     int delNum{ 0 };
  7.     int pos{1};
  8.     int digit{ 0 };
  9.     int mult{ 1 };
  10.  
  11.     std::cout << "Enter number: ";
  12.     std::cin >> num;
  13.     num > 0 ? pos = 1 : pos = -1;
  14.     num *= pos;
  15.  
  16.     while (num)
  17.     {
  18.         digit = num % 10;
  19.         num /= 10;
  20.         if (digit != 3 and digit != 6)
  21.         {
  22.             delNum += digit * mult;
  23.             mult *= 10;
  24.         }
  25.     }
  26.    
  27.     std::cout << "Corrected (maybe) number: " << delNum * pos << "\n";
  28. }
Advertisement
Add Comment
Please, Sign In to add comment