Advertisement
vallec

bukayo saka

Jan 17th, 2023
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1.  
  2. #include <stdio.h>
  3. #include <math.h>
  4.  
  5. int main()
  6. {
  7. 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");
  8. printf("Da se smenqt mestata na redovete sudurjashti maksimalniq i minimalniq element na matricata.\n");
  9. printf("Avtor: ..........\n");
  10.  
  11. int A[10][10];
  12.  
  13. for(int i = 0; i < 10; i++){
  14. for(int j = 0; j < 10; j++){
  15. printf("A[%d][%d] = ", i, j);
  16. scanf("%d", &A[i][j]);
  17. }
  18. }
  19.  
  20. printf("---------------\n");
  21.  
  22. for(int i = 0; i < 10; i++){
  23. for(int j = 0; j < 10; j++){
  24. printf("A[%d][%d] = %d\n", i, j, A[i][j]);
  25. }
  26. }
  27.  
  28. printf("---------------\n");
  29.  
  30. int minEl = 100;
  31. int minElRow = 0;
  32. int maxEl = 0;
  33. int maxElRow = 0;
  34.  
  35. for(int i = 0; i < 10; i++){
  36. for(int j = 0; j < 10; j++){
  37. if(A[i][j] < minEl){
  38. minEl = A[i][j];
  39. minElRow = i;
  40. }
  41. if(A[i][j] > maxEl){
  42. maxEl = A[i][j];
  43. maxElRow = i;
  44. }
  45. }
  46. }
  47.  
  48. printf("Min element: %d, row: %d\n", minEl, minElRow);
  49. printf("Max element: %d, row: %d\n", maxEl, maxElRow);
  50.  
  51. int minRow = fmin(minElRow, maxElRow);
  52. int maxRow = fmax(minElRow, maxElRow);
  53. for(int i = 0; i < 10; i++){
  54. int temp = A[minRow][i];
  55. A[minRow][i] = A[maxRow][i];
  56. A[maxRow][i] = temp;
  57. }
  58.  
  59. printf("---------------\n");
  60.  
  61. for(int i = 0; i < 10; i++){
  62. for(int j = 0; j < 10; j++){
  63. printf("A[%d][%d] = %d\n", i, j, A[i][j]);
  64. }
  65. }
  66.  
  67. return 0;
  68.  
  69. }
  70.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement