-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain-4-1.cpp
34 lines (31 loc) · 1.11 KB
/
main-4-1.cpp
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
#include <iostream>
#include <string>
using namespace std;
extern int secondSmallestSum(int *numbers,int length);
int main(){
int array_length = 0;
int negative_to_positive = 0;
int sub_array_addition = 0;
cout <<"\n Enter array_length: ";
cin >> array_length;
if (array_length < 0){
negative_to_positive = abs(array_length);
cout <<"\n"<<negative_to_positive<<" \n";
int *array = new int[negative_to_positive];
for (int h = 0; h < negative_to_positive; h++){
cout<<"\n Enter a number: ";
cin >> array[h];
}
sub_array_addition = secondSmallestSum(array,array_length);
cout <<"\n The addition of the second smallest contiguous array is: "<<sub_array_addition<<"\n\n";
}
else {
int *array = new int[array_length];
for (int h = 0; h < array_length; h++){
cout<<"\n Enter a number: ";
cin >> array[h];
}
sub_array_addition = secondSmallestSum(array,array_length);
cout <<"\n The addition of the second smallest possible contiguous array is: "<<sub_array_addition<<"\n\n";
}
}