1 #include<stdio.h> 2 #include<algorithm> 3 #include<string.h> 4 using namespace std; 5 struct TT 6 { 7 int a,b; 8 }tt[60]; 9 bool cmp(TT a,TT b) 10 { 11 return a.b<b.b; 12 } 13 int main() 14 { 15 int back(int n); 16 int t,n,m,i; 17 scanf("%d",&t); 18 while(t--) 19 { 20 scanf("%d%d",&n,&m); 21 for(i=0;i<=m-n;i++) 22 { 23 tt[i].a=i+n; 24 tt[i].b=back(i+n); 25 //printf("%d ",tt[i].b); 26 } 27 sort(tt,tt+i,cmp); 28 for(i=0;i<=m-n;i++) 29 printf("%d ",tt[i].a); 30 printf(" "); 31 } 32 return 0; 33 } 34 int back(int n) 35 { 36 int a[6],m; 37 if(n/10==0) 38 return n; 39 else if(n/100==0) 40 { 41 a[0]=n%10; 42 a[1]=n%100/10; 43 return a[0]*10+a[1]; 44 } 45 else if(n/1000==0) 46 { 47 a[0]=n%10; 48 a[1]=n%100/10; 49 a[2]=n%1000/100; 50 return a[0]*100+a[1]*10+a[2]; 51 } 52 else if(n/10000==0) 53 { 54 a[0]=n%10; 55 a[1]=n%100/10; 56 a[2]=n%1000/100; 57 a[3]=n%10000/1000; 58 return a[0]*1000+a[1]*100+a[2]*10+a[3]; 59 } 60 else if(n/100000==0) 61 { 62 a[0]=n%10; 63 a[1]=n%100/10; 64 a[2]=n%1000/100; 65 a[3]=n%10000/1000; 66 a[4]=n%100000/10000; 67 return a[0]*10000+a[1]*1000+a[2]*100+a[3]*10+a[4]; 68 } 69 else if(n/1000000==0) 70 { 71 a[0]=n%10; 72 a[1]=n%100/10; 73 a[2]=n%1000/100; 74 a[3]=n%10000/1000; 75 a[4]=n%100000/10000; 76 a[5]=n/100000; 77 return a[0]*100000+a[1]*10000+a[2]*1000+a[3]*100+a[4]*10+a[5]; 78 } 79 }