Advertisement
damch

totalno razl

Nov 19th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4.  
  5. int main() {
  6. int n,x;
  7. scanf("%d %d",&n,&x);
  8. int cuvajx=x;
  9. int j1,j2;
  10. int d1,d2;
  11. int i;
  12. int z1=0,z2=0;
  13. int j,z;
  14. int max=0;
  15. int cifrix=0,cifrin=0;
  16. int cuvajn;
  17. int cifran,cifrax;
  18. while(cuvajx>0) {
  19. cifrix++;
  20. cuvajx/=10;
  21. }
  22. for(i=n-1; i>=0; i--) {
  23. cuvajn=i;
  24. cifrin=0;
  25. z1=0;
  26. z2=0;
  27. cuvajn=i;
  28. d1=1;
  29. d2=1;
  30. while(cuvajn>0) {
  31. cifrin++;
  32. cuvajn/=10;
  33. }
  34. for(j1=1; j1<=cifrin; j1++) {
  35. cifran=i/d1%10;
  36. d2=1;
  37. z2=0;
  38. for(j2=1; j2<=cifrix; j2++) {
  39. cifrax=x/d2%10;
  40. if(cifran!=cifrax)
  41. z2++;
  42.  
  43. d2*=10;
  44. }
  45. if(z2==cifrix)
  46. z1++;
  47.  
  48. d1*=10;
  49. }
  50. if(z1==cifrin)
  51. {
  52. max=i;
  53. break;
  54. }
  55.  
  56. }
  57. printf("%d",max);
  58.  
  59. return 0;
  60.  
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement