0
Hi why its not work, can somebody help me
2 Antworten
+ 4
Some stray characters , had to delete them and insert spaces again wherever necessary .
Probably your code wasn't working because the function was called before definition .
Correct code ,
void Reverse(int *a, int *b){
if (a < b){
*a += *b;
*b = *a - *b;
*a -= *b;
Reverse(a + 1, b - 1);
}
}
int main() {
int array []= {2, 3, 5, 4, 9, 8};
int i, n;
n = sizeof(array) / sizeof(*array);
for(i = 0; i < n; i++)
printf("%d ", array[i]);
Reverse(array, array + n - 1);
puts("\n");
for(i = 0; i < n; i++)
printf("%d ", array[i]);
return 0;
}
Edit: Check this thread about if function can be called before definition,
https://stackoverflow.com/questions/21487894/can-we-call-functions-before-defining-it
+ 1
Thanks a lot🙏