helpp

Write your question here.
hello guys, need some help:

You will be given n integer numbers. Print the two numbers whose difference is the closest. Show any two, if there are many numbers giving the same minimum difference.

Please note, that this is not a homework site. We won't do your homework for you. However we are always willing to help solve problems you encountered, correct mistakes you made in your code and answer your questions.

We didn't see your attemts to solve this problem youself and so we cannot correct mistakes you didn't made and answer questions you didn't ask. To get help you should do something yourself and get real problems with something. If your problem is "I don't understand a thing", then you should go back to basics and study again.

Nevertheless,

You have to store those n numbers. I would put them into std::vector.

Sort the numbers. See http://www.cplusplus.com/reference/algorithm/sort/

Calculate adjacent differences. See http://www.cplusplus.com/reference/numeric/adjacent_difference/

Find minimum difference. See http://www.cplusplus.com/reference/algorithm/min_element/

Show corresponding values. See http://www.cplusplus.com/reference/iterator/distance/

Topic archived. No new replies allowed.