Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- void main()
- {
- //int array[] = { 1,2,7,5,9,6 };
- int array[] = { 1,2,8,5,9,6 };
- int re = findEqual(array, sizeof(array) / sizeof(int));
- printf("returned: %d", re);
- }
- int findEqual(int* arr, int n)
- {
- for (int i = 1; i < n - 1; i++)
- {
- if (arr[i - 1] + arr[i + 1] == arr[i])
- return 1;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment