include iostream include stdlib include string include conio define LE

 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
#include <iostream>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
#define LEN 100
using namespace std;
class massiv{
private:
int mas[LEN];
int n;
public:
massiv();
massiv(int, int[]);
void Output();
double func(int *);
};
int main(){
int summ = 0;
massiv massive;
double arifmSumm = massive.func(&summ);
cout << summ << ", " << arifmSumm;
}
massiv::massiv(){
cout <<"\nVvedite razmer massiva kol= ";
cin>>n;
for(int q=0;q<n;q++){
cout<<"Wvedite mas["<<(q+1)<<"]= ";
cin>>mas[q];
}
}
massiv::massiv(int m, int x[]){
n = m;
for (int q=0; q<n; q++)
mas[q] = x[q];
}
void massiv::Output(){
cout <<"\n\t Massive:"<<"\n\n";
for(int q=0;q<n;q++)
cout<<mas[q]<<" ";
cout << endl;
}
double massiv::func(int *summ){
int kolvo;
double arifmSumm = 0;
int k, l;
cout << "Vvedite K i L" << endl;
cin >> k >> l;
*summ = k + l;
k--;
l--;
kolvo = n - (l - k) - 1;
for (int q=0; q<k; q++)
arifmSumm += mas[q];
for (int q=l+1; q<n; q++)
arifmSumm += mas[q];
return arifmSumm / kolvo;
}