Advertisement
a53

CifreGen

a53
Feb 4th, 2020
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. int a,b,n,i,p=1,nmin=0,nmax=0;
  5. int corect(int k,int p)
  6. {
  7. int ok=1;
  8. while(p>1)
  9. {
  10. if(k%10<a||k%10>b)
  11. ok=0;
  12. k/=10;
  13. p/=10;
  14. }
  15. if(ok)
  16. return 1;
  17. else
  18. return 0;
  19. }
  20. int main()
  21. {
  22. cin>>a>>b>>n;
  23. for(i=1;i<=n;i++)
  24. {
  25. nmin+=a*p;
  26. p*=10;
  27. }
  28. p=1;
  29. for(i=1;i<=n;i++)
  30. {
  31. nmax+=b*p;
  32. p*=10;
  33. }
  34. p/=10;
  35. for(i=nmin;i<=nmax;i++)
  36. if(corect(i,p))
  37. cout<<i<<'\n';
  38. return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement