0
已解决
董宇昊
初级启示者
初级启示者
#include<iostream>
#include<cmath>
using namespace std;
int a[1001],t;
int main() {
int n, c;
cin >> n >> c;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
if (abs(a[i] - a[j] == c)) {
t++;
}
}
}
cout << t/2;
return 0;
}
为什么样例输出1???