@Monte-Cristo
2794 / 1380 / 30
Регистрация: 07.03.2009
Сообщений: 4,446
|
24.05.2009, 18:18
|
|
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
| #include <iostream>
using namespace std;
int somefunc1(int* A, int n)
{
int kol = 0;
for (int i=0; i<n; i++)
if (A[i] < 0) kol++;
if (kol>3) return kol;
return 0;
}
int somefunc2(int* A, int n)
{
int kol = 0;
for (int i=0; i<n; i++)
if (*(A+i) < 0) kol++;
if (kol>3) return kol;
return 0;
}
int main()
{
const int m=5;
const int n=5;
int X[m][n];
// заполняем случыйными числами и выводим на экран
srand(time(0));
for (int i=0; i<m; i++)
{
for (int j=0; j<n; j++)
{
X[i][j] = rand()%10-7;
cout.width(3);
cout << X[i][j];
}
cout << endl;
}
cout << endl;
for (int i=0; i<m; i++)
{
cout << "Row " << i << " func1 = " << somefunc1(X[i],n) << " func2 = " << somefunc2(X[i],n) << endl;
}
system("pause");
return 0;
} |
|
0
|