Advertisement
vallec

Kristiqn

Dec 12th, 2022
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.19 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 dva masiva A[N,N] i B[N,N], kudeto dannite sa celi chisla v intervala [-1000;1000]. Programata da izvurshi slednite deistviq:\n");
  7. printf("Da se nulirat elementite v masiva A, koito sa po - golemi ot MAX element na suotvetnata kolona ot masiva B\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("Vavedi golemina na A i 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. for(int i = 0; i < n; i++){
  26. for(int j = 0; j < n; j++){
  27. printf("B[%d][%d] = ", i, j);
  28. scanf("%d", &B[i][j]);
  29. }
  30. }
  31.  
  32. printf("---------------\n");
  33.  
  34. for(int i = 0; i < n; i++){
  35. for(int j = 0; j < n; j++){
  36. printf("A[%d][%d] = %d\n", i, j, A[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 maxNums[n];
  49.  
  50. for(int col = 0; col < n; col++){
  51. int temp[n];
  52. for(int row = 0; row < n; row++){
  53. temp[row] = B[row][col];
  54. }
  55. int max = temp[0];
  56.  
  57. for (int i = 0; i < n; i++) {
  58. if(temp[i] > max)
  59. max = temp[i];
  60. }
  61. maxNums[col] = max;
  62. }
  63. int changes = 0;
  64. for(int i = 0; i < n; i++){
  65. for(int j = 0; j < n; j++){
  66. if(A[i][j] > maxNums[j]){
  67. A[i][j] = 0;
  68. changes++;
  69. }
  70. }
  71. }
  72.  
  73. printf("Rezultati: \n");
  74. printf("---------------\n");
  75. for(int i = 0; i < n; i++){
  76. for(int j = 0; j < n; j++){
  77. printf("A[%d][%d] = %d\n", i, j, A[i][j]);
  78. }
  79. }
  80. printf("\n");
  81. printf("Broi promeneni elementi: %d\n", changes);
  82.  
  83. return 0;
  84.  
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement