machkovskitomche

matrici/zbir od red vo niza(ima problem)

Aug 17th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.69 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #define max 30
  4.  
  5. int main()
  6. {
  7. int A[max][max],a[max],sumared[max];
  8. int redici,koloni,i,j,k;
  9. printf("Vnesete gi dimenziite na matricata:\n");
  10. scanf("%d%d",&redici,&koloni);
  11. printf("Vnesete gi elemenite na matricata so dimenzii %dx%d\n",redici,koloni);
  12. for(i=0;i<redici;i++)
  13. {
  14.     for(j=0;j<koloni;j++)
  15.     {
  16.         scanf("%d",&A[i][j]);
  17.     }
  18. }
  19. for(i=0;i<redici;i++)
  20. {
  21.     for(j=0;j<koloni;j++)
  22.     {
  23.         if(A[i][j]%2==0)
  24.         {
  25.             sumared[i]+=A[i][j];
  26.         }
  27.     }
  28. }
  29. for(i=0;i<redici;i++)
  30. {
  31.     for(k=0;k<redici;k++)
  32. {
  33.     a[k]=sumared[i];
  34. }
  35. }
  36. for(k=0;k<redici;k++)
  37. {
  38.     printf("a[%d]=%d",k,a[k]);
  39. }
  40. return 0;
  41. }
Add Comment
Please, Sign In to add comment