fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int unique(long long int number)
  4. {
  5. char seen[10] = {0};
  6.  
  7. while (number) {
  8. int digit = number % 10;
  9.  
  10. number /= 10;
  11. if (digit < 0) {
  12. /*
  13.   * The number was negative. Make it positive.
  14.   * (Note: Checking the number is negative before the while
  15.   * loop could fail when number is LLONG_MIN, so do it here
  16.   * instead.)
  17.   */
  18. digit = -digit;
  19. number = -number;
  20. }
  21. if (seen[digit]++)
  22. return 0; /* not unique */
  23. }
  24. return 1; /* unique */
  25. }
  26. int main(){
  27. cout<<unique(2021);
  28.  
  29. }
Success #stdin #stdout 0s 5548KB
stdin
Standard input is empty
stdout
Standard output is empty