Advertisement
SalmaYasser

Untitled

Jan 8th, 2020
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. bool confusingNumber(int N) {
  2.  
  3. int new_n = 0;
  4.  
  5. vector <int> valid_new_rotate {0, 1,-1,-1,-1,-1, 9,-1, 8, 6};
  6. int old = N;
  7. while (N)
  8. {
  9. int dig = N % 10;
  10. if (valid_new_rotate[dig] == -1)
  11. {
  12. return false;
  13. }
  14. new_n = new_n *10 + valid_new_rotate[dig] ;
  15. cout << new_n << endl;
  16. N /= 10;
  17. }
  18.  
  19.  
  20. return new_n != old;
  21.  
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement