文章
61
粉丝
137
获赞
18
访问
38.3k
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
while(cin >> n){
int sum = 0;
int myset1[n];
int myset2[n];
for(int i = 0; i < n; i++)
cin >> myset1[i];
for(int i = 0; i < n; i++)
cin >> myset2[i];
sort(myset1, myset1+n);
bool res[n] = {0};
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
if(myset1[i] == myset2[j]){
res[i] = true;
sum++;
break;
}
}
}
cout << sum << endl;
for(int i = 0; i < n; i++)
if(res[i])
cout <<myset1[i] << " ";
cout << endl;
}
return 0;
}
登录后发布评论
暂无评论,来抢沙发