BorjanCrvenkov

funkcii sp labs

Aug 19th, 2020
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. int obratenBroj(int broj){
  4. int temp=0;
  5. while(broj>0){
  6. temp=temp*10;
  7. temp=temp+broj%10;
  8. broj/=10;
  9. }
  10. return temp;
  11. }
  12. int sumaNaCifri (int broj){
  13. int suma=0;
  14. int temp1=broj;
  15. while(temp1>0){
  16. suma+=temp1%10;
  17. temp1/=10;
  18. }
  19. return suma;
  20. }
  21. void pecatiVoInterval (int a,int b){
  22. int i;
  23. for(i=a;i<=b;i++){
  24. if((i+obratenBroj(i))%sumaNaCifri(i+obratenBroj(i))==0){
  25. printf("%d\n", i);
  26. }
  27.  
  28. }
  29. }
  30. int main () {
  31. int a,b;
  32. scanf("%d %d", &a, &b);
  33. pecatiVoInterval(a,b);
  34. return 0;
  35.  
  36. }
Add Comment
Please, Sign In to add comment