Strange Sort time limit: +Ms | Memory Limit:65535KB Difficulty:1
-
-
Describe
-
Recently, Dr Kong has designed a robot bill. This machine man is very clever and can do a lot of things. Only the understanding of the natural number is different from the human, it is reading from right to left. For example, when it sees 123, it will understand 321. Let it compare 23 with 15 which one big, it says 15 big. The reason is that the brain thinks it's 32 versus 51 in comparison. Let's say it compares 29 with 30, it says 29.
Given bill two natural numbers a and B, let it sort all the numbers in the [a, b] interval by small to large. How do you think it is sorted?
-
input
-
first row: n indicates how many sets of test data. (2<=n<=5) The
Next has n rows, and each row has two positive integers a B represents the interval range of the elements to be sorted. (1<=a<=b<=200000 b-a<=50)
-
output
-
for each row of test data, output a row for all ordered elements, with a space between the elements.
-
-
28
-
22
-
-
10 8 9 1 1
-
30-All-you-could-be-in-a-V-all-in-a-page
-
source
-
fifth session of Henan Province Program design competition
-
uploader /dt>
-
acm_ Li Rubing
<span style= "FONT-SIZE:24PX;" > #include <iostream> #include <algorithm> #include <string.h> #include <stdio.h>using namespace Std;struct num{int zhnum;int fannum;int Xuhao;}; int cmp (num a,num b) {return a.fannum<b.fannum;//ascending}int main () { num a[70]; int N,a,b,i,j,k,len; Char s[7],b[7]; cin>>n; while (n--) { cin>>a>>b;//total b-a+1 number for (i=0;i<=b-a;i++) { k=0; A[i].zhnum=a+i; a[i].xuhao=i; sprintf (S, "%d", a[i].zhnum); Len=strlen (s); for (j=len-1;j>=0;j--) b[k++]=s[j];b[k]= ' + '; SSCANF (b, "%d", &a[i].fannum); } Sort (a,a+b-a+1,cmp); for (i=0;i<b-a;i++) cout<<a[i].zhnum<< ""; cout<<a[i].zhnum<<endl; } return 0;} </span>
Odd sort of