TY_FOR @ 2017-12-24 23:41:29
#include<stdio.h>
int n,q,i,j,code[100000],need,output,exchange,result[10000];
int bit[]={1,10,100,1000,10000,100000,1000000,10000000};
int main()
{
chengji();
for(i=1;i<=n;i++)
{
printf("%d",result[i]);
}
return 0;
}
int chengji()
{
scanf("%d%d",&n,&q);
for(i=1;i<=n;i++)
scanf("%d",&code[i]);
for(j=0;j<=n;j++)
{
for(i=0;i<=n-j;i++)
{
if(code[i]<code[i+1])
{
exchange=code[i];
code[i]=code[i+1];
code[i+1]=exchange;
}
}
}
while(q--)
{
scanf("%d%d",&need,&output);
for(i=1;i<=n;i++)
if(code[i]%bit[need]==output)
{
result[i]=code[i];
}
else
{
result[i]=-1;
}
}
}
by arfa @ 2017-12-25 13:46:37
还是乖乖打sort吧
by _LiM @ 2017-12-25 18:53:22
这道题我考试的时候写的冒泡,然后自己拍出了错误。。。
乖乖sort