#include <stdio.h>
void masking( int *, int, int *, int * ) ;
int main ( ) {
int a[ 6 ] = { 1 , 2 , 3 , 0 , 4 , 8 } ;
int b[ 3 ] = { 1 , 2 , 7 } ;
int c[ 6 ] = masking( int * a, 6 , int * b, int * c) ;
for ( int i= 0 ; i< 7 ; i++ )
return 0 ; }
masking( int* arr, int s, int * m, int * op) {
int j= 1 ;
for ( int i= 0 ; i< s; i++ ) {
if ( i== 0 )
op[ i] = ( arr[ i] * m[ j] ) + ( 0 * m[ j- 1 ] ) + ( arr[ i+ 1 ] * m[ j+ 1 ] ) ;
else {
if ( i== s- 1 )
op[ i] = ( arr[ i] * m[ j] ) + ( arr[ i- 1 ] * m[ j- 1 ] ) + ( 0 * m[ j+ 1 ] ) ;
else
op[ i] = ( arr[ i] * m[ j] ) + ( arr[ i- 1 ] * m[ j- 1 ] + arr[ i+ 1 ] * m[ j+ 1 ] ) ; }
}
return ; }
I2luY2x1ZGUgPHN0ZGlvLmg+CnZvaWQgbWFza2luZyhpbnQgKixpbnQsaW50ICosaW50ICopOwppbnQgbWFpbiAoKXsKICAgICAgICBpbnQgYVs2XT17MSwyLDMsMCw0LDh9OwogICAgICAgIGludCBiWzNdPXsxLDIsN307CiAgICAgICAgaW50IGNbNl09bWFza2luZyhpbnQgKmEsNixpbnQgKmIsaW50ICpjKTsKICAgICAgICBmb3IgKGludCBpPTA7aTw3O2krKykKICAgICAgICAgICAgICAgIHByaW50ZigiJWQiLGNbaV0pOwogICAgICAgIHJldHVybiAwO30KbWFza2luZyhpbnQqYXJyLGludCBzLGludCAqbSxpbnQgKm9wKXsKICAgICAgICBpbnQgaj0xOwogICAgICAgIGZvciAoaW50IGk9MDtpPHM7aSsrKXsKICAgICAgICAgICAgICAgIGlmIChpPT0wKQogICAgICAgICAgICAgICAgICAgICAgICBvcFtpXT0oYXJyW2ldKm1bal0pKygwKm1bai0xXSkrKGFycltpKzFdKm1baisxXSk7CiAgICAgICAgICAgICAgICBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGk9PXMtMSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcFtpXT0oYXJyW2ldKm1bal0pKyhhcnJbaS0xXSptW2otMV0pKygwKm1baisxXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGVsc2UKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcFtpXT0oYXJyW2ldKm1bal0pKyhhcnJbaS0xXSptW2otMV0rYXJyW2krMV0qbVtqKzFdKTt9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuO30K
stdout
#include <stdio.h>
void masking(int *,int,int *,int *);
int main (){
int a[6]={1,2,3,0,4,8};
int b[3]={1,2,7};
int c[6]=masking(int *a,6,int *b,int *c);
for (int i=0;i<7;i++)
printf("%d",c[i]);
return 0;}
masking(int*arr,int s,int *m,int *op){
int j=1;
for (int i=0;i<s;i++){
if (i==0)
op[i]=(arr[i]*m[j])+(0*m[j-1])+(arr[i+1]*m[j+1]);
else {
if (i==s-1)
op[i]=(arr[i]*m[j])+(arr[i-1]*m[j-1])+(0*m[j+1]);
else
op[i]=(arr[i]*m[j])+(arr[i-1]*m[j-1]+arr[i+1]*m[j+1]);}
}
return;}