forked from kennyledet/Algorithm-Implementations
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBisoye
More file actions
38 lines (34 loc) · 723 Bytes
/
Copy pathBisoye
File metadata and controls
38 lines (34 loc) · 723 Bytes
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
#include <iostream>
#include<list>
#include<ctime>
using namespace std;
const int N(6);
long encrypt(int numbers[]){
int N = 6;
long sum=0;
long lsum = 1;
for (int i = 0; i < N; i++){
numbers[i] = numbers[i] + 1;
for (int j = 0; j < N; j++){
printf("+{%ld*%ld}",lsum,numbers[j]);
lsum *= numbers[j];
}
cout <<" = "<<lsum<< endl;
if (lsum>sum)
sum = lsum;
lsum = 1;
numbers[i] = numbers[i] - 1;
}
return sum;
}
int main(){
int a[N] = {1000,999,998,997,996,995};
//int a[N] = {1,3,2,1,1,3};
/*for (int i = 0; i < N; i++){
a[i] = rand() % 998 +2;
cout << a[i] << "-";
}*/
printf("\nAnswer: %ld",encrypt(a));
//system("pause");
return 0;
}