Advertisement
a53

CifreGen3

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