Advertisement
jordanov

[3.1]Благ број

Oct 31st, 2017
621
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int blag(int n)
  5. {
  6. int cifra;
  7. int tmp = n;
  8. while(tmp != 0)
  9. {
  10. cifra= tmp % 10;
  11. if(cifra % 2 != 0)
  12. {
  13. return 0;
  14. }
  15. tmp /= 10;
  16. }
  17. return 1; //blag e!
  18. }
  19.  
  20. int main()
  21. {
  22. int n,m,i;
  23. int flag = 1;
  24. int bb = 0;
  25. scanf("%d%d", &n,&m);
  26. for(i=n;i<=m;i++)
  27. {
  28. if(!blag(i))
  29. {
  30. flag = 0;
  31. } else {
  32. flag = 1;
  33. bb = i;
  34. break;
  35. }
  36. }
  37. if(flag)
  38. printf("%d", bb);
  39. else
  40. printf("NE");
  41. return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement