pengqiushi @ 2022-08-09 21:28:53
代码如下:
#include<iostream>
#include<algorithm>
using namespace std;
int book[1005],a[1005];
int cmp(int i,int j){
for(int c=1; c<=10000; c*=10)
if(a[i]/c%10==book[j]){
return book[j];
}
return -1;
}
int main()
{
int n,m;
cin>>n>>m;
for(int i=1; i<=n; i++)
cin>>book[i];
sort(book+1,book+1+n);
for(int i=1; i<=m; i++)
cin>>a[i];
for(int i=1; i<=m; i++){
int q=0;
for(int j=1; j<=n; j++){
if(cmp(i,j)!=-1){
cout<<cmp(i,j)<<endl;
q=1;
break;
}
}
if(q==0)
cout<<"-1"<<endl;
}
return 0;
}
by _sin_ @ 2022-08-09 21:36:04
前面还有一个操作码的长度没有读取
by pengqiushi @ 2022-08-09 21:57:28
还是输出-1......
by FeelGood @ 2022-08-10 09:24:41
@pengqiushi 你的cmp函数写错了,并且操作码的长度也没有读取。
by pengqiushi @ 2022-08-10 09:30:29
@FeelsGood ,好的,我一会从私信里看