0
what is my wrong?
Implement function maxabsinlst(lst), which returns the maximum absolute value of the elements in the array. For example, given a array lst: [-19, -3, 20, -1, 0, -25], the function should return 25. MY ATTEMPT long arr[1000]; int max; int absoluteValue; for(int i = 0; i < 6; i++){ cin>>arr[i]; if(arr[i]<0){ absoluteValue = arr[i] * (-1); if (arr[i] > max) max = arr[i]; if(absoluteValue>max) cout << absoluteValue << endl; else { cout << max << endl; } } }
2 Respuestas
+ 2
thank you :)