fork download
  1. #include <stdio.h>
  2. void masking(int *,int,int *,int *);
  3. int main (){
  4. int a[6]={1,2,3,0,4,8};
  5. int b[3]={1,2,7};
  6. int c[6]=masking(int *a,6,int *b,int *c);
  7. for (int i=0;i<7;i++)
  8. printf("%d",c[i]);
  9. return 0;}
  10. masking(int*arr,int s,int *m,int *op){
  11. int j=1;
  12. for (int i=0;i<s;i++){
  13. if (i==0)
  14. op[i]=(arr[i]*m[j])+(0*m[j-1])+(arr[i+1]*m[j+1]);
  15. else {
  16. if (i==s-1)
  17. op[i]=(arr[i]*m[j])+(arr[i-1]*m[j-1])+(0*m[j+1]);
  18. else
  19. op[i]=(arr[i]*m[j])+(arr[i-1]*m[j-1]+arr[i+1]*m[j+1]);}
  20. }
  21. return;}
  22.  
Success #stdin #stdout 0.02s 25628KB
stdin
Standard input is empty
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;}