文章
34
粉丝
89
获赞
2
访问
18.5k
#include<bits/stdc++.h>
using namespace std;
struct Point{
int a;
int b;
bool operator < (const Point &po) const{//运算符重载
if(this -> a < po.a){
return true;
}else if(this -> a == po.a){
return this -> b < po.b;
}else{
return false;
}
}
};
int flag [35][35] = {0};//标记数组 用于判重
vector<Point> vec;
int main(){
int n;
cin >> n;
int a[n];
for(int i = 0;i < n;i++){
cin >> a[i];
}
for(int i = 0;i < n;i++){
int n1 = a[i];
for(int j = 0; j < n;j++){
if(j == i) continue;
int n2 = a[j];
if(flag[n1][n2] == 0){//之前该点没出现过
flag[n1][n2] = 1;
Point p = {n1,n2};
vec.push_back(p);
}
}
}
sort(vec.begin(),vec.end());
int len = vec.size();
for(int i = 0;i < le...
登录后发布评论
(1,1)(2,2)不算重复
(2,2)(2,2)才算重复