We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- C
- Arrays and Strings
- Array Reversal
- Discussions
Array Reversal
Array Reversal
Sort by
recency
|
851 Discussions
|
Please Login in order to post a comment
include
int main() { int n; scanf("%d",&n);
}
You guys over complicate so much
include
include
int main() { int num, arr, i; scanf("%d", &num); arr = (int) malloc(num * sizeof(int)); for(i = 0; i < num; i++) { scanf("%d", arr + i); }
}
Saw a lot of code that prints the array just in reverse which is a perfect solution for this problem. If you want to actually reverse the array in your code and use it further I implemented the reversal with a xor swap. This way you don't need a temporary array or variable.
include
include
int main() { int num, arr, i; scanf("%d", &num); arr = (int) malloc(num * sizeof(int)); for(i = 0; i < num; i++) { scanf("%d", arr + i); }
}