[ссылка заблокирована по решению администрации проекта]
#include
#include
#include
#include
using namespace std;
int main(int argc, char *argv[])
{
setlocale (LC_CTYPE, "rus");
// квадратная матрица
int Array[3][3] = {{1,2,3},
{4,5,6},
{7,8,9}};
int max = 0, min = 10;
int i,j;
for (i = 0; i <= 2; i++)
{
for (j = 0; j <= 2; j++)
{
Array[j]= rand();
};
};
int ctolbec1=0, ctolbec2=0;
for (i = 0; i <= 2; i++)
{
for (j = 0; j <= 2; j++)
{
if ( Array[j] > max)
{max = Array[j];
ctolbec1 = j;}
if ( Array[j] < min)
{min = Array[j];
ctolbec2 = j;};
cout << Array[j] << "\t";
};
cout << endl;
};
cout << ctolbec1 << endl;
cout << ctolbec2 << endl;
// обмениваем местами столбцы
int buff;
for ( i=0; i <= 2; i++) {
buff = Array [ctolbec1];
Array[ctolbec1] = Array[ctolbec2];
Array [ctolbec2] = buff; }
//cout << Array[3][3] << endl;
for (i = 0; i <= 2; i++)
{
for (j = 0; j <= 2; j++)
{
cout << Array[j] << "\t";
};
cout << endl;
};
system("PAUSE");
return EXIT_SUCCESS;
}
Гугли на найдёшь. А лучше по ссылке.