#include
#include
using namespace std;
int max_value(int n){
int max=0,i=0;
cin>>n;
vector arr(n);
while(cin >> arr[i] && i!=n){
arr.push_back(arr[i]);
i++;
}
for(int i=0;i<n;i++){
if(max < arr[i]){
max = arr[i];
}
}
return max;
}
int main() {
int n;
cin >> n;
cout << max_value(n);
return 0;
}
My code is running fine on gfg’s ide but here on coding blocks it is giving 0 as output for the following input.
4
-3
-8
-4
-2`
