This is a simple sort, the reason why put this problem above, because I am in this problem is too much WA, WA 7 times, in the middle to find out
A mistake, that is, in the penultimate and the penultimate equal circumstances I did not output their number, corrected or WA, finally I found that the original is each group
Output a blank line between data ..... Pit me for a long time, always thought that there are empty lines behind each group ...
Release code:
#include <stdio.h> #include <stdlib.h> #include <string.h>//char a[100005];char a[100005][1000]; CHAR b[100005][1000];int cmp (const void *a,const void *b) {return strcmp ((char *) A, (char *) b);} int main () {int n,t,i,j,lena,k;scanf ("%d", &t), while (t--) {memset (A, ' n '), sizeof (a)), memset (b, ' n ', sizeof (b)); scanf ("%d", &n), for (k=0; k<n; k++) {scanf ("%s", A[k]), Lena = strlen (A[k]), j=0;for (i=0;i<lena; i++) {if (a[k][i ]!= '-') {if (a[k][i]>= ' a ' &&a[k][i]<= ' Z ') {switch (A[k][i]) {case ' a ': Case ' B ': Case ' C ': b[k][j++]= ' 2 '; Break;case ' D ': Case ' E ': Case ' F ': b[k][j++]= ' 3 '; Break;case ' G ': Case ' H ': Case ' I ': b[k][j++]= ' 4 '; Break;case ' J ': Case ' K ': Case ' L ': b[k][j++]= ' 5 '; Break;case ' M ': Case ' N ': Case ' O ': b[k][j++]= ' 6 '; Break;case ' P ': Case ' R ': Case ' S ': b[k][j++]= ' 7 '; Break;case ' T ': Case ' U ': Case ' V ': b[k][j++]= ' 8 '; Break;case ' W ': Case ' X ': Case ' Y ': b[k][j++]= ' 9 '; break;} } else b[k][j++]=a[k][i];}} b[k][j]= ' + ';//puts ("###################");-//printf ("%s\n", B[k]);} Qsort (B,n,sizEOF (B[0]), CMP),//puts ("**********************"),//for (i=0; i<n; i++)//puts (b[i]); int Sum=1;int Flag=0;int flag=0 for (k=0; k<n-1; k++) {//puts (b[k]), if (!strcmp (b[k],b[k+1)) {sum++;flag=1;if (sum==2) {for (j=0; b[k][j]!= '); j + + {printf ("%c", b[k][j]); if (j==2) printf ("-");} Flag=1;} if (k+1==n-1) printf ("%d\n", sum);//printf ("%s", B[k]);} ELSE{IF (flag) {printf ("%d\n", sum); sum=1;} flag=0;}} if (flag==0) puts ("No duplicates."); if (t!=0) puts ("");} return 0;}
UVA 755 (487--3279) sort