@R136a1
143 / 112 / 15
Регистрация: 14.04.2011
Сообщений: 261
|
13.01.2012, 13:53
|
|
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
61
62
63
64
65
66
67
68
69
70
71
72
73
| #include <iostream>
#include <cstdlib>
#include <ctime>
#include <iomanip>
int minf(int a, int b)
{
return a > b ? b : a;
}
int main()
{
const int row = 3;
const int column = 4;
int matr[row][column] = {0};
int tmp_i = 0, tmp_j = 0;
int max, min;
bool ExitFlag = false;
srand(time(NULL));
matr[2][3] = 5;
for(int i = 0; i < row; i++)
{
for(int j = 0; j < column; j++)
{
if(i < 2)
matr[i][j] = 10 + rand() % 50;
std::cout << std::setw(5) << matr[i][j];
}
std::cout << std::endl;
}
while(!ExitFlag)
{
bool minInColumn = true;
max = matr[tmp_i][0];
for(int j = 0; j < column; j++)
if(matr[tmp_i][j] > max)
{
max = matr[tmp_i][j];
tmp_j = j;
}
for(int i = 0; i < row; i++)
if(matr[tmp_i][tmp_j] > matr[i][tmp_j])
minInColumn = false;
if(minInColumn)
{
std::cout << "Такой элемент есть! matr[" << tmp_i << "][" << tmp_j << "]: "
<< matr[tmp_i][tmp_j] << std::endl;
ExitFlag = true;
}
else
{
if(tmp_i < row - 1)
tmp_i++;
else
{
std::cerr << "Такого элемента нет" << std::endl;
ExitFlag = true;
}
}
}
return 0;
} |
|
0
|