Advertisement
Guest User

sas

a guest
Dec 11th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. int obratenBroj (int broj) {
  4. int result=0, q, rem;
  5. q=broj;
  6. while(q) {
  7.  
  8. rem=q%10;
  9. result = result*10 + rem;
  10. q=q/10;
  11. }
  12. return result;
  13.  
  14. }
  15.  
  16. int sumaNaCifri (int broj) {
  17. int t, sum=0, lastDigit;
  18. t=broj;
  19. while(t) {
  20. lastDigit=t%10;
  21. sum+=lastDigit;
  22. t/=10;
  23. }
  24. return sum;
  25. }
  26.  
  27. void pecatiVoInterval(int a, int b) {
  28. for(int i=a; i<=b; i++) {
  29.  
  30. if((i + obratenBroj(i))%sumaNaCifri(i + obratenBroj(i))==0)
  31. printf("%d\n", i );
  32. }
  33.  
  34. }
  35.  
  36. int main () {
  37.  
  38. int a,b;
  39. scanf("%d %d", &a, &b);
  40. pecatiVoInterval(a,b);
  41.  
  42.  
  43.  
  44.  
  45. return 0;
  46.  
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement