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 masiva A[10, 10], kudeto dannite sa chisla v intervala [0;99]. Programata da izvurshi slednite deistviq:\n");
- printf("Da se smenqt mestata na redovete sudurjashti maksimalniq i minimalniq element na matricata.\n");
- printf("Avtor: ..........\n");
- int A[10][10];
- for(int i = 0; i < 10; i++){
- for(int j = 0; j < 10; j++){
- printf("A[%d][%d] = ", i, j);
- scanf("%d", &A[i][j]);
- }
- }
- printf("---------------\n");
- for(int i = 0; i < 10; i++){
- for(int j = 0; j < 10; j++){
- printf("A[%d][%d] = %d\n", i, j, A[i][j]);
- }
- }
- printf("---------------\n");
- int minEl = 100;
- int minElRow = 0;
- int maxEl = 0;
- int maxElRow = 0;
- for(int i = 0; i < 10; i++){
- for(int j = 0; j < 10; j++){
- if(A[i][j] < minEl){
- minEl = A[i][j];
- minElRow = i;
- }
- if(A[i][j] > maxEl){
- maxEl = A[i][j];
- maxElRow = i;
- }
- }
- }
- printf("Min element: %d, row: %d\n", minEl, minElRow);
- printf("Max element: %d, row: %d\n", maxEl, maxElRow);
- int minRow = fmin(minElRow, maxElRow);
- int maxRow = fmax(minElRow, maxElRow);
- for(int i = 0; i < 10; i++){
- int temp = A[minRow][i];
- A[minRow][i] = A[maxRow][i];
- A[maxRow][i] = temp;
- }
- printf("---------------\n");
- for(int i = 0; i < 10; i++){
- for(int j = 0; j < 10; j++){
- printf("A[%d][%d] = %d\n", i, j, A[i][j]);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement