Advertisement
vallec

georgi

Dec 12th, 2022
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. int main()
  5. {
  6. printf("Da se sustavi programa za obrabotka na masiva A[N,N], kudeto dannite sa celi chisla v intervala [-1000;1000]. Programata da izvurshi slednite deistviq:\n");
  7. printf("Da se nulirat elementite ot masiva A, za koito sumata sus suotvetniq element ot masiva B e chetno chislo prinadlejashto na zadaden interval [K, L]\n");
  8. printf("Da se opredeli broq na promenenite elementi v masiva A\n");
  9. printf("Avtor: ..........\n");
  10.  
  11. int n;
  12.  
  13. printf("Enter size of the array A and B: ");
  14. scanf("%d", &n);
  15. int A[n][n];
  16. int B[n][n];
  17.  
  18. for(int i = 0; i < n; i++){
  19. for(int j = 0; j < n; j++){
  20. printf("A[%d][%d] = ", i, j);
  21. scanf("%d", &A[i][j]);
  22. }
  23. }
  24.  
  25. printf("---------------\n");
  26.  
  27. for(int i = 0; i < n; i++){
  28. for(int j = 0; j < n; j++){
  29. printf("A[%d][%d] = %d\n", i, j, A[i][j]);
  30. }
  31. }
  32.  
  33. for(int i = 0; i < n; i++){
  34. for(int j = 0; j < n; j++){
  35. printf("B[%d][%d] = ", i, j);
  36. scanf("%d", &B[i][j]);
  37. }
  38. }
  39.  
  40. printf("---------------\n");
  41.  
  42. for(int i = 0; i < n; i++){
  43. for(int j = 0; j < n; j++){
  44. printf("B[%d][%d] = %d\n", i, j, B[i][j]);
  45. }
  46. }
  47.  
  48. int k, l;
  49. printf("K = ");
  50. scanf("%d", &k);
  51. printf("L = ");
  52. scanf("%d", &l);
  53. int changes = 0;
  54.  
  55.  
  56. for(int i = 0; i < n; i++){
  57. for(int j = 0; j < n; j++){
  58. int sum = A[i][j] + B[i][j];
  59. if(sum % 2 == 0 && sum >= k && sum <= l){
  60. A[i][j] = 0;
  61. changes++;
  62. }
  63. }
  64. }
  65.  
  66. printf("a)---------------\n");
  67.  
  68. for(int i = 0; i < n; i++){
  69. for(int j = 0; j < n; j++){
  70. printf("A[%d][%d] = %d\n", i, j, A[i][j]);
  71. }
  72. }
  73.  
  74. printf("b)---------------\n");
  75. printf("Promeneni elementi: %d", changes);
  76.  
  77.  
  78. return 0;
  79.  
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement