@MikeSoft
3916 / 1781 / 85
Регистрация: 21.11.2009
Сообщений: 2,540
|
10.05.2010, 23:20
|
|
Роза!!!, первое задание:
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
| //---------------------------------------------------------------------------
#include <iostream.h>
#include <conio.h>
//---------------------------------------------------------------------------
int main()
{
const int N = 10;
int a[N] = {NULL};
int sum = 0, count = 0;
for (int i = 0; i < N; i++) {
a[i] = -10 + rand()%20;
cout << a[i] << " ";
}
for (int i = 0; i < N; i++) {
if (a[i] > 0) {
sum+=a[i];
count++;
}
}
cout << "\n\nAverage = " << float(sum)/float(count);
getch();
return 0;
}
//--------------------------------------------------------------------------- |
|
Второе задание:
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
| //---------------------------------------------------------------------------
#include <iostream.h>
#include <conio.h>
//---------------------------------------------------------------------------
int main()
{
const int N = 10;
int a[N][N] = {NULL};
int sum = 0, count = 0;
int mn = 0;
cout << "Enter value: ";
cin >> mn;
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
a[i][j] = -10 + rand()%20;
cout << a[i][j] << " ";
if (j == N-1) { cout << endl; }
}
}
cout << endl << endl;
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
a[i][j] *= mn;
cout << a[i][j] << " ";
if (j == N-1) { cout << endl; }
}
}
getch();
return 0;
}
//--------------------------------------------------------------------------- |
|
1
|