Codeforces 994A. Fingerprints

题意

从x数组中找到最多的y数组中有的数字,按在x数组中出现的顺序输出。

注意

这题x数组和y数组都不会出现重复数字。

代码

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int x[15],y[15];
int main(){
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    for(int i = 1;i <= n; ++i) cin >> x[i];
    for(int i = 1;i <= m; ++i) cin >> y[i];
    for(int i = 1;i <= n; ++i){
        for(int j = 1;j <= m; ++j){
            if(x[i] == y[j]){
                cout << x[i] << " ";
            }
        }
    }
    cout << endl;
    return 0;
}

猜你喜欢

转载自www.cnblogs.com/zhangjiuding/p/9192538.html