Bài đăng phổ biến

6/02/2019

Problem 1

Write a program that takes an integer N and an array of N integers as input. Your program should output the minimum absolute difference between two different elements from the array. Note: The integer N will be given in the first line and the array of N integers will be given in the second line (each integer separated by a single space).

Note2: Note that two elements are different if they're in different positions.

Example:

Case 1:

For the input provided as follows:

3
1 2 3

Output of the program will be:

1

Description of the output:

Both pairs (1,2) and (2,3) give difference 1.

Case 2:

For the input provided as follows:

4
1 1 1 1

Output of the program will be:

0

0 comments:

Đăng nhận xét