By DePaul Dimadis
Choose your prefered Language: greek_flag uk_flag

Enter values ​​in a one-dimensional array of positive integers in the range [1-999], N (N = known). Numbers can be entered in any way (scanf_s command, using random number creation function), provided that a valid validity check is in place.
Create a new table that includes the differences of the elements in the original table, in pairs, in absolute terms, as follows (difference of 1st to 2nd, 3rd to 4th element, and so on), sorted in ascending order, without using the sorting procedure. If the N is unnecessary then the differences for the first N-1 elements will be calculated.

Example:

Initial array, N=10:

37 71 19 25 53 19 8 5 77 24

 

Differences:

|37 - 71|=34, |19 - 25|=6, |53 - 19|=34, |8 - 5|=3, |77 - 24|=53

New sorted array ascending order:

 

3 6 34 34 53