avr39ripe

cppDebugTask

Jul 5th, 2021
767
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. int main()
  4. {
  5.     int num{ 124567 };
  6.     int newNum{ 0};
  7.     int mul{ 1 };
  8.     bool operation{true};
  9.  
  10.     while (num)
  11.     {
  12.         int digit{ (num % 10) * mul };
  13.  
  14.         newNum += (operation  ? digit * 10 :  digit / 10);
  15.         num /= 10;
  16.         mul *= 10;
  17.        
  18.         operation = !operation;
  19.     }
  20.  
  21.     std::cout << newNum << '\n';
  22. }
RAW Paste Data