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
62
63
64
65
#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();
int func(int *);
};
int main(){
int proizved = 1;
massiv massive;
int index = massive.func(&proizved);
cout << proizved << ", " << index;
}
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;
}
int massiv::func(int *proizved){
int d, index;
cout << "Vvedite d" << endl;
cin >> d;
for (int q=0; q<n; q++)
if (mas[q] >= d){
for (int w=n-1; w>=q; w--){
*proizved = *proizved * mas[w];
mas[w+1] = mas[w];
}
mas[q] = d;
index = q;
*proizved = *proizved * d;
break;
}
for (int q=0; q<n+1; q++)
cout << mas[q] << " ";
cout << endl;
return index;
}