#include<stdio.h>
void array_multiplication(int A[], int OUTPUT[], int n)
{
// Initializing left and right
int left = 1;
int right = 1;
// Initialize the output array
int i = 0;
for (i = 0; i < n; i++)
OUTPUT[i] = 1;
for (i = 0; i < n; i++)
{
// Code obtained from http://w...content-available-to-author-only...s.com
// Feel free to copy but please acknowledge if possible
OUTPUT[i] *= left;
OUTPUT[n - 1 - i] *= right;
// The variable left stores the multiplication of
// all elements on the left
left *= A[i];
// The variable right stores the multiplication of
// all elements on the right
right *= A[n - 1 - i];
}
}
int main(void)
{
int arr[] = {4, 3, 2, 1, 2};
int OUTPUT[5] = {0};
array_multiplication(arr, OUTPUT, 5);
int i = 0;
for(i=0; i<5; i++)
return 0;
}
I2luY2x1ZGU8c3RkaW8uaD4KCnZvaWQgYXJyYXlfbXVsdGlwbGljYXRpb24oaW50IEFbXSwgaW50IE9VVFBVVFtdLCBpbnQgbikKewoJLy8gSW5pdGlhbGl6aW5nIGxlZnQgYW5kIHJpZ2h0CglpbnQgbGVmdCA9IDE7CglpbnQgcmlnaHQgPSAxOwoJCgkvLyBJbml0aWFsaXplIHRoZSBvdXRwdXQgYXJyYXkKCWludCBpID0gMDsKCWZvciAoaSA9IDA7IGkgPCBuOyBpKyspCgkJT1VUUFVUW2ldID0gMTsJCgoJZm9yIChpID0gMDsgaSA8IG47IGkrKykKCXsKCQkvLyBDb2RlIG9idGFpbmVkIGZyb20gaHR0cDovL3cuLi5jb250ZW50LWF2YWlsYWJsZS10by1hdXRob3Itb25seS4uLnMuY29tCgkJLy8gRmVlbCBmcmVlIHRvIGNvcHkgYnV0IHBsZWFzZSBhY2tub3dsZWRnZSBpZiBwb3NzaWJsZQoJCU9VVFBVVFtpXSAqPSBsZWZ0OwoJCU9VVFBVVFtuIC0gMSAtIGldICo9IHJpZ2h0OwoJCQoJCS8vIFRoZSB2YXJpYWJsZSBsZWZ0IHN0b3JlcyB0aGUgbXVsdGlwbGljYXRpb24gb2YKCQkvLyBhbGwgZWxlbWVudHMgb24gdG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