fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. void search_min_id(int a[3][4],int i1,int j1,int i2,int j2,int *xid,int *yid)
  5. {
  6. int min,x,y;
  7. *xid=i1;
  8. *yid=j1;
  9. min=a[i1][j1];
  10. for (x=i1;x<=i2;x++)
  11. {
  12. for (y=j1;y<=j2;y++)
  13. {
  14. if(min>a[x][y])
  15. {
  16. min=a[x][y];
  17. *xid=x;
  18. *yid=y;
  19. }
  20. }
  21. }
  22. return;
  23. }
  24.  
  25. int main()
  26. {
  27. int x,i1=0,i2=0,j1=0,j2=0,a[3][4],N=3,M=4;
  28.  
  29. for (int i = 0; i < N; ++i)
  30. {
  31. for (int j = 0; j < M; ++j)
  32. {
  33. cin >> a[i][j];
  34. }
  35. }
  36. search_min_id(a,1,1,3,2,&i1,&j1);
  37. search_min_id(a,1,3,3,4,&i2,&j2);
  38. x=a[i1][j1];
  39. a[i1][j1]=a[i2][j2];
  40. a[i2][j2]=x;
  41.  
  42. for (int i = 0; i < N; ++i)
  43. {
  44. for (int j = 0; j < M; ++j)
  45. {
  46. cout << a[i][j];
  47. }
  48. }
  49. return 0;
  50. }
  51.  
Success #stdin #stdout 0s 3300KB
stdin
Standard input is empty
stdout
134513936134520013134519696134513813-1217166364-12187097871345196521345148821-1080960508-1080960500-1215805992