-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsavenewfile09.cpp
More file actions
108 lines (103 loc) · 2.45 KB
/
Copy pathsavenewfile09.cpp
File metadata and controls
108 lines (103 loc) · 2.45 KB
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#include <iostream>
#include <cmath>
#include <clocale>
using namespace std;
//int main()
//{
// setlocale(LC_ALL, "Rus");
// int a[5]={ 1,2,3,4,5 };
// int i, n, k = 0;
// //cout << "Ââåñòè n" << endl;
// //cin >> n;
// n = 5;
// srand(time(0)); //ñëó÷àéíûé ãåíåðàòîð ÷èñåë
// for (i = 0; i < n; i++)
// {
// //cout << a[i] << endl;
// a[i] = rand() % 2;
// cout << a[i] << " " << endl;
// } //[-9;9] - rand()%9+1;
// // [a;b] -> (a-b+1)+a;
// // [10;90] = rand()%90+10; (90-10+1)+10;
// //[-99;-10] = rand()%90-99; (-10-(-99+1)+(-99))
// for (i = 0; i < n; i++)
// if (i % 2 != 0 && a[i] % 2 == 0) k++;
// cout << "Êîë-âî " << k << endl;
//}
//int main()
//{
// int a[5];
// int max = 1;
// int i, n, k = 0;
// n = 5;
// for (i = 0; i < n; i++)
// {
// if (max == 1 && a[i] % 2 == 0) max = a[i];
// if (a[i] > max && a[i] % 2 == 0) max = a[i];
// }
//}
//int main()
//{
// setlocale(LC_ALL, "Rus");
// int a[5]={ 1,2,3,4,5 };
// int i, n, k = 0;
// int max = 1;
// bool f = 1;
// //cout << "Ââåñòè n" << endl;
// //cin >> n;
// n = 5;
// //srand(time(0)); //ñëó÷àéíûé ãåíåðàòîð ÷èñåë
// for (i = 0; i < n; i++)
// {
// //cout << a[i] << endl;
// //a[i] = rand() % 90 - 99;;
// cout << a[i] << " " << endl;
// } //[-9;9] - rand()%9+1;
// // [a;b] -> (a-b+1)+a;
// // [10;90] = rand()%90+10; (90-10+1)+10;
// //[-99;-10] = rand()%90-99; (-10-(-99+1)+(-99))
// for (i = 0; i < n-1; i++)
// {
// /* if (max == 1 && a[i] % 2 == 0) max = a[i];
// if (a[i] > max && a[i] % 2 == 0) max = a[i];*/
// if (a[i] > a[i + 1]) f = 0;
// //cout << f;
// }
// if (f == 0) cout << "no" << endl;
// else cout << "yes" << endl;
// cout << "Êîë-âî " << max << endl;
// }
void main()
{
setlocale(LC_ALL, "Rus");
const int N = 10;
double a[N];
for (int i = 0; i < N; i++)
{
a[i] = rand() * pow(-1, rand());
}
cout << "Èñõîäíûé ìàññèâ";
for (int i = 0; i < N; i++)
{
cout << a[i] << " ";
}
int mino = 0;
for (int i = 0; i < N; i++)
{
if (a[i] < mino)
mino = a[i];
}
if (mino == 0)
cout << endl << "Â ìàññèâå íåò îòðèöòåëüíûõ ýëåìåíòîâ" << endl;
else cout << endl << "Ìèíèìàëüíûé îòðèöàòåëüíûé ýëåìåíò" << mino << endl;
int s = 0; double k = 0;
cout << "Âñå ïîëîæèòåëüíûå ýë-òû ìàññèâà: ";
for (int i = 0; i < N; i++)
{
if (a[i] > 0) {
cout << " " << a[i];
s += a[i]; k++;
}
}
cout << endl << "Èõ ñðåäíåå àðèôìåòè÷åñêîå: " << s / k;
}