Topic 1099: Suffix substring sequencing
time limit:1 seconds
Memory limit:32 MB
Special question: No
submitted:2857
Resolution:1219
-
Title Description:
-
For a string, sort the suffix substring, for example grain
Its substrings are:
Grain
Rain
Ain
Inch
N
The substrings are then sorted in dictionary order, i.e.:
Ain,grain,in,n,rain
-
Input:
-
Each case is a row of strings.
-
Output:
-
Sort the substring output
-
Sample input:
-
Grain
-
Sample output:
-
Aingraininnrain
#include <stdio.h> #include <stdlib.h> #include <string.h>int cmp (const void *a,const void *b) { Return strcmp ((char*) A, (char*) b); Char s[1000][1000];int main (int argc, char *argv[]) { while (~scanf ("%s", S[0]) { int len=strlen (s[0 ]); for (int i=1;i<len;++i) { strcpy (s[i],s[0]+i); } Qsort (s,len,1000,cmp); for (int i=0;i<len;++i) { printf ("%s\n", S[i]); } } return 0;} /************************************************************** problem:1099 user:kirchhoff Language:c result:accepted time:0 ms memory:1888 kb********************************************** ******************/
Nine degrees oj 1099 suffix string sort