Advertisement
Guest User

Untitled

a guest
Jul 21st, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int q;
  7. int qarr[10];
  8. int karr[10];
  9. int copy;
  10. int size=0;
  11.  
  12. cin >> q;
  13.  
  14. copy = q;
  15. for(; copy>0; copy/=10){
  16. size++;
  17. }
  18.  
  19. for(int i=0; i<10; i++){
  20. qarr[i]=0;
  21. }
  22.  
  23. copy = q;
  24. for(int i=0; copy>0; i++, copy/=10){
  25. qarr[copy % 10]++;
  26. }
  27.  
  28.  
  29. for (int k = pow(10.0, size-1); k < pow(10.0, size); k++)
  30. {
  31. for(int i=0; i<10; i++){
  32. karr[i]=0;
  33. }
  34. copy = k;
  35.  
  36. for(int i=0; copy>0; i++, copy/=10){
  37. karr[copy % 10]++;
  38. }
  39.  
  40. for (int i = 0; i < 10; i++) {
  41. if(karr[i]!=qarr[i]) break;
  42. if(i==9) cout<<k<<endl;
  43. }
  44. }
  45.  
  46. cout << endl;
  47. system("pause");
  48. return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement