So I hava an unsorted array of 30 ints like 340, 6401 1280, and so on random numbers. I have int x which was cined by user. I need to find which value in array is nearest down (lower, smaller,less) to that x value. How to do such thing?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You could use
std::max_element()with a custom comparison operator: