-->
当前位置:首页 > 题库

PROGRAMMING:Adjacent number pairs

Luz5年前 (2021-05-10)题库419
Given n different integers, ask how many pairs of integers there are, and their values are exactly 1 different.
###Input format:
The first line of input contains an integer n, which represents the number of given integers.
The second line contains the given n integers.
###Output format:
Output an integer that represents the number of pairs whose values differ exactly by 1.
###Input example:
```in
six
10 2 6 3 7 8
```
###Output example:
```out
three
```
###Example description:
The number pairs whose values differ exactly by 1 include (2, 3), (6, 7), (7, 8).
  
###Scale and convention of evaluation case:
1 < = n < = 1000, the given integer is not more than 10000 non negative integers.







answer:If there is no answer, please comment