How to solve the Maximum Product problem?

Правка en1, от husain_Motaz, 2023-07-30 20:56:01

how can i solve the Maximum Product problem the link of the problem :https://codeforces.net/gym/454092/problem/A and here is my code:

include

using namespace std;

int main() { long long arraySize = 0; long long maxProduct = 0; cin >> arraySize;

long long arr[arraySize];

for (int i=0;i<arraySize;i++) {
    cin >> arr[i];

}//end for -looping around the arraySize-

for (int j=0;j<arraySize;j++) {
    if (arr[j]*arr[j+1]>=maxProduct) {
       maxProduct = arr[j] * arr[j + 1];
    }
}//end for -searching for the max pair-

cout << maxProduct << endl;
return 0;

}//end main

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский husain_Motaz 2023-07-30 20:56:01 658 Initial revision (published)