@IIIa66uMEM6eP
заставил Бендера
437 / 293 / 10
Регистрация: 05.12.2010
Сообщений: 1,659
|
28.04.2011, 18:24
|
|
Не по теме:
MILAN, и правда, обычно массивы сразу и заполняю, а тут забыл..
Добавлено через 29 минут

Сообщение от rodrigezrobert
а с помощью цикла какой-то примерчик?
Взгляни на задание из лабы..
C++ | 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
| #include <cstdlib>
#include <iostream>
#include <cmath>
#include <clocale>
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[i][j]= rand();
};
};
int ctolbec1=0, ctolbec2=0;
for (i = 0; i <= 2; i++)
{
for (j = 0; j <= 2; j++)
{
if ( Array[i][j] > max)
{max = Array[i][j];
ctolbec1 = j;}
if ( Array[i][j] < min)
{min = Array[i][j];
ctolbec2 = j;};
cout << Array[i][j] << "\t";
};
cout << endl;
};
cout << ctolbec1 << endl;
cout << ctolbec2 << endl;
// обмениваем местами столбцы
int buff;
for ( i=0; i <= 2; i++) {
buff = Array [i][ctolbec1];
Array[i][ctolbec1] = Array[i][ctolbec2];
Array [i][ctolbec2] = buff; }
//cout << Array[3][3] << endl;
for (i = 0; i <= 2; i++)
{
for (j = 0; j <= 2; j++)
{
cout << Array[i][j] << "\t";
};
cout << endl;
};
system("PAUSE");
return EXIT_SUCCESS;
} |
|
3
|