Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- int main()
- {
- 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");
- printf("Da se nulirat elementite v masiva A, koito sa po - golemi ot MAX element na suotvetnata kolona ot masiva B\n");
- printf("Da se opredeli broq na promenenite elementi v masiva A\n");
- printf("Avtor: ..........\n");
- int n;
- printf("Vavedi golemina na A i B: ");
- scanf("%d", &n);
- int A[n][n];
- int B[n][n];
- for(int i = 0; i < n; i++){
- for(int j = 0; j < n; j++){
- printf("A[%d][%d] = ", i, j);
- scanf("%d", &A[i][j]);
- }
- }
- for(int i = 0; i < n; i++){
- for(int j = 0; j < n; j++){
- printf("B[%d][%d] = ", i, j);
- scanf("%d", &B[i][j]);
- }
- }
- printf("---------------\n");
- for(int i = 0; i < n; i++){
- for(int j = 0; j < n; j++){
- printf("A[%d][%d] = %d\n", i, j, A[i][j]);
- }
- }
- printf("---------------\n");
- for(int i = 0; i < n; i++){
- for(int j = 0; j < n; j++){
- printf("B[%d][%d] = %d\n", i, j, B[i][j]);
- }
- }
- int maxNums[n];
- for(int col = 0; col < n; col++){
- int temp[n];
- for(int row = 0; row < n; row++){
- temp[row] = B[row][col];
- }
- int max = temp[0];
- for (int i = 0; i < n; i++) {
- if(temp[i] > max)
- max = temp[i];
- }
- maxNums[col] = max;
- }
- int changes = 0;
- for(int i = 0; i < n; i++){
- for(int j = 0; j < n; j++){
- if(A[i][j] > maxNums[j]){
- A[i][j] = 0;
- changes++;
- }
- }
- }
- printf("Rezultati: \n");
- printf("---------------\n");
- for(int i = 0; i < n; i++){
- for(int j = 0; j < n; j++){
- printf("A[%d][%d] = %d\n", i, j, A[i][j]);
- }
- }
- printf("\n");
- printf("Broi promeneni elementi: %d\n", changes);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement