2
I need help with arrays! :/

So I've got a code where the player inputs the amount of numbers for the list then will have to input the numbers for list they decided it to be. However, i manage to get the sum to add the total. It's just finding the lowest number to the largest number And I can't find anything about it.

You are viewing a single comment. View All
Answered by
themaka (176)
[earned 5 cycles]
View Answer
1

I'm assuming you're using python? If yes, then you can simply do list.sort() to sort all values in ascending order. Then just get the first and last value from the list and there you have it, there are also similar methods in different languages.

1

@TheDrone7 To get the first and last values from a list in python do

first = list[0]
last = list[-1]
1

@ArchieMaclean well ik but helping means to show the way not leading the way. Hope you understand.

2

@TheDrone7 This is C++, you can tell from some of the syntax

1

@TheDrone7 wait he hadnt posted his code when u said this nvm

1

@SPQR I know, he hadn't posted the code when I replied, so I automatically assumed that it was python code. But the technique I offered wasn't only limited to python, he could still sort the list and get the first and last element from the sorted array or vector.

1

@TheDrone7 I wasn't trying to say that you were unhelpful or anything, and that's a perfectly reasonable assumption to make. I just wanted to let you know what language this is. As far as I know, though, there isn't any native way to sort an array in C++. However, I could be wrong.

1

@SPQR you're not wrong as far as I know and I was just saying that you were right, so no need to apologise. And thank you.