内存分配2014北邮机试题B

#include
#include
using namespace std;


int main()
{
int n, N,M;
int temp,flag;
int i,j;
int buf1[101]={0}, buf2[101]={0};
cin>>n;
while(n--){
cin>>N;
for( i=1;i<=N;i++){
int x;
cin>>x;
buf1[i]=x;
}
cin>>M;
for( i=1;i<=M;i++){
int x;
cin>>x;
buf2[i]=x;
}
sort(buf1+1,buf1+N+1);//搞明白
for( i=1;i<=M;i++){
temp=0;
for(j=1;j<=N;j++){
if(buf2[i]<=buf1[j]){
temp=buf1[j];
for(int k=j;k<=N;k++){
buf1[k]=buf1[k+1];
}
break;
}


}
if(0==temp){
printf("NULL ");
}else{printf("%d ",temp);}
}
printf("\n");
}
system ("pause");
return 0;
}

你可能感兴趣的:(bupt,计算机上机题)