Advertisement
Guest User

Untitled

a guest
Jan 31st, 2015
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. cifren_zbir(int a, int b)
  5. { if(a==0)
  6. return 0;
  7. if(b==0)
  8. return a%10 + cifren_zbir(a/10, b);
  9. if((a%10-b%10)<0)
  10. {
  11. return (a%10-b%10)*(-1) + cifren_zbir(a/10, b/10);
  12. }
  13. else return (a%10-b%10) + cifren_zbir(a/10, b/10);
  14. }
  15.  
  16.  
  17. int main()
  18. { int a[100], n, i, min, x;
  19. scanf("%d", &n);
  20. for(i=0;i<n;i++)
  21. {
  22. scanf("%d", &a[i]);
  23. }
  24. min=cifren_zbir(a[0], a[1]);
  25. for(i=1;i<n-1;i++)
  26. {
  27. x=cifren_zbir(a[i], a[i+1]);
  28.  
  29. if(min > x)
  30. {
  31. min=x;
  32. }
  33. }
  34. printf("%d", min);
  35.  
  36. return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement