fork download
  1. #include <stdio.h>
  2.  
  3. void modify(int *arr, int size) {
  4. int *ptr = arr + size - 1;
  5. while (ptr >= arr) {
  6. *ptr = (*ptr) * (*ptr) - *(arr + (ptr - arr) / 2);
  7. ptr--;
  8. }
  9. }
  10.  
  11. int main() {
  12. int arr[5] = {1, 2, 3, 4, 5};
  13. modify(arr, 5);
  14. int *p = arr;
  15. int sum = 0;
  16. for (int i = 0; i < 5; i++) {
  17. sum += *(p++);
  18. if (i % 2 == 0) {
  19. sum -= arr[i/2];
  20. }
  21. }
  22. printf("%d\n", sum);
  23. return 0;
  24. }
Success #stdin #stdout 0s 5288KB
stdin
Standard input is empty
stdout
36