## 题目描述
现有 $N$ 名同学参加了期末考试,并且获得了每名同学的信息:语文、数学、英语成绩(均为不超过 $150$ 的自然数)。如果某对学生 $\text{<}i,j\text{>}$ 的每一科成绩的分差都不大于 $5$,且总分分差不大于 $10$,那么这对学生就是“旗鼓相当的对手”。现在想知道这些同学中,有几对“旗鼓相当的对手”?同样一个人可能会和其他好几名同学结对。
## 输入格式
第一行一个正整数 $N$。
接下来 $N$ 行,每行三个整数,其中第 $i$ 行表示第 $i$ 名同学的语文、数学、英语成绩。最先读入的同学编号为 $1$。
## 输出格式
输出一个整数,表示“旗鼓相当的对手”的对数。
## 样例 #1
### 样例输入 #1
```
3
90 90 90
85 95 90
80 100 91
```
### 样例输出 #1
```
2
```
## 提示
数据保证,$2 \le N\le 1000$ 且每科成绩为不超过 $150$ 的自然数。
代码如下:
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();int count=0;
int mat[]=new int [n];
int eng[]=new int[n];
int chi[]=new int[n];
int tot[]=new int[n];
for (int i = 0; i <mat.length; i++) {
chi[i]=sc.nextInt();
mat[i]=sc.nextInt();
eng[i]=sc.nextInt();
tot[i]=chi[i]+eng[i]+mat[i];
}
for (int i = 0; i < n; i++) {
for (int j = i+1; j < n; j++) {
if((Math.abs(chi[i]-chi[j])<=5)&&(Math.abs(mat[i]-mat[j])<=5)&&(Math.abs(eng[i]-eng[j])<=5)&&(Math.abs(tot[i]-tot[j])<=10)){
count++;
}
}
}
System.out.println(count);
}
}
这道题说实话用二维数组最合适,但是二维数组掌握不好,就是直接暴力解法。