Advertisement
Guest User

keoki

a guest
Jul 16th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4.  
  5.  
  6. #ifndef DEBUG
  7. #define DEBUG(...) printf(__VA_ARGS__)
  8. #endif
  9.  
  10. #define MAXN 100001
  11. int subsum(int *a, int n) {
  12. if(*a == a[n-1]) return 0;
  13. return *a + subsum(++a, n)*(-1);
  14. }
  15.  
  16.  
  17. int main() {
  18. int n, a[MAXN];
  19. scanf("%d", &n);
  20. for (int i = 0; i < n; ++i) {
  21. scanf("%d", &a[i]);
  22. }
  23. printf("%d\n", subsum(a, n));
  24. return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement