#include <iostream>
using namespace std;
void search_min_id(int a[3][4],int i1,int j1,int i2,int j2,int *xid,int *yid)
{
int min,x,y;
*xid=i1;
*yid=j1;
min=a[i1][j1];
for (x=i1;x<=i2;x++)
{
for (y=j1;y<=j2;y++)
{
if(min>a[x][y])
{
min=a[x][y];
*xid=x;
*yid=y;
}
}
}
return;
}
int main()
{
int x,i1=0,i2=0,j1=0,j2=0,a[3][4],N=3,M=4;
for (int i = 0; i < N; ++i)
{
for (int j = 0; j < M; ++j)
{
cin >> a[i][j];
}
}
search_min_id(a,0,0,2,1,&i1,&j1); // Исправлено
search_min_id(a,0,2,2,3,&i2,&j2); // тут
x=a[i1][j1];
a[i1][j1]=a[i2][j2];
a[i2][j2]=x;
for (int i = 0; i < N; ++i)
{
for (int j = 0; j < M; ++j)
{
cout << a[i][j] << "\t";
}
cout << "\n";
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwogCnZvaWQgc2VhcmNoX21pbl9pZChpbnQgYVszXVs0XSxpbnQgaTEsaW50IGoxLGludCBpMixpbnQgajIsaW50ICp4aWQsaW50ICp5aWQpCnsKICBpbnQgbWluLHgseTsKICAqeGlkPWkxOwogICp5aWQ9ajE7CiAgbWluPWFbaTFdW2oxXTsKICBmb3IgKHg9aTE7eDw9aTI7eCsrKQogIHsKICAgIGZvciAoeT1qMTt5PD1qMjt5KyspCiAgICB7CiAgICAgIGlmKG1pbj5hW3hdW3ldKQogICAgICB7CiAgICAgICAgbWluPWFbeF1beV07CiAgICAgICAgKnhpZD14OwogICAgICAgICp5aWQ9eTsKICAgICAgfQogICAgfQogIH0KICByZXR1cm47Cn0KIAppbnQgbWFpbigpCnsKICBpbnQgeCxpMT0wLGkyPTAsajE9MCxqMj0wLGFbM11bNF0sTj0zLE09NDsKIAogIGZvciAoaW50IGkgPSAwOyBpIDwgTjsgKytpKQogIHsKICAgIGZvciAoaW50IGogPSAwOyBqIDwgTTsgKytqKQogICAgewogICAgICBjaW4gPj4gYVtpXVtqXTsKICAgIH0KICB9CiAgc2VhcmNoX21pbl9pZChhLDAsMCwyLDEsJmkxLCZqMSk7IC8vINCY0YHQv9GA0LDQstC70LXQvdC+CiAgc2VhcmNoX21pbl9pZChhLDAsMiwyLDMsJmkyLCZqMik7IC8vINGC0YPRggogIHg9YVtpMV1bajFdOwogIGFbaTFdW2oxXT1hW2kyXVtqMl07CiAgYVtpMl1bajJdPXg7CiAKICBmb3IgKGludCBpID0gMDsgaSA8IE47ICsraSkKICB7CiAgICBmb3IgKGludCBqID0gMDsgaiA8IE07ICsraikKICAgIHsKICAgICAgY291dCA8PCBhW2ldW2pdIDw8ICJcdCI7CiAgICB9CiAgICAKICAgIGNvdXQgPDwgIlxuIjsKICB9CiAgcmV0dXJuIDA7Cn0K