Rejack

[Lec. #7] Exc. 4

Mar 12th, 2024 (edited)
1,048
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.34 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. void main()
  4. {
  5.     //int array[] = { 1,2,7,5,9,6 };
  6.     int array[] = { 1,2,8,5,9,6 };
  7.  
  8.     int re = findEqual(array, sizeof(array) / sizeof(int));
  9.  
  10.     printf("returned: %d", re);
  11. }
  12.  
  13. int findEqual(int* arr, int n)
  14. {
  15.     for (int i = 1; i < n - 1; i++)
  16.     {
  17.         if (arr[i - 1] + arr[i + 1] == arr[i])
  18.             return 1;
  19.     }
  20.  
  21.     return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment