Alx09

ex 16

May 1st, 2020
358
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int f1(int n, int m) {
  5. if (m < 1 || n < 1)
  6. return 0;
  7. if (n == 1 && m == 1)
  8. return 0;
  9. if (m > n)
  10. return 1 + f1(m / 2, n) + f1(m - m / 2, n);
  11. return 1 + f1(m, n/2) + f1(m, n - n /2);
  12. }
  13.  
  14. int main() {
  15. int m , n;
  16. FILE *f;
  17. f = fopen("in.txt", "r"); //deschidere in mod citire fiser
  18.  
  19. fscanf(f, "%d%d", &n, &m);
  20. fclose(f);
  21. f = fopen("out.txt", "w");
  22. fprintf(f, "%d", f1(n, m));
  23.  
  24. return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment