文章
61
粉丝
137
获赞
18
访问
39.7k
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >> n;
//用set去重
set<int> myset;
for(int i = 0; i < n; i++){
int tmp;
cin >> tmp;
myset.insert(tmp);
}
//去重后输入数组
int arr[myset.size()];
int j = 0;
for(auto i = myset.begin(); i != myset.end(); i++){
arr[j] = *i;
j++;
}
//组合为2元组
for(int i = 0; i <myset.size(); i++){
for(j = 0;j < myset.size();j++){
if(i == j) continue;
printf("(%d,%d)\n", arr[i], arr[j]);
}
}
return 0;
}
登录后发布评论
https://noobdream.com/post/373141/