Sample Input
2
Hello world!
.
ABC-CDE aa1bb2cc3 AAS '(TEST )...
.
Sample output
2
Hello 1
World 1
7
Aa 1
AAS 1
ABC 2
BB 1
CC 1
CDE 1
Test 1
This question is simple statistics and then sorted, but pay attention to the following points:
First, each group of data does not contain only one row, but each row does not contain more than 1000 characters. Therefore, one row is read until the end of reading a row is '.'
Second, when the last character in a row is a letter, you did not process the last word. For example, this line is "ABC. ABC ", the result should be ABC 2, but yourProgramABC 1 will be output, because you didn't process the last word ABC, because it is because you only process the previous word when it is not a letter, but if it is a letter at the end, it will be wrong.
# Include <stdio. h> # include <string. h> int main () {int T, number; int I, j; int K, L; char a [1000] [1001]; int B [1000]; char temp2 [2, 1001]; char temp [1001]; int temp3; int length; char en [3]; scanf ("% d", & number); getchar (); for (t = 1; t <= number; t ++) {k = 0; L = 0; memset (A, '\ 0', sizeof ()); memset (B, 0, sizeof (B); While (true) {gets (temp); If (temp [0] = '. '& strlen (temp) = 1) {break;} length = strlen (temp); for (I = 0; I <length; I ++) {If (temp [I]> = 'A' & temp [I] <= 'Z') {temp2 [L ++] = temp [I];} else if (temp [I]> = 'A' & temp [I] <= 'Z') {temp2 [L ++] = temp [I]-32 ;} else {temp2 [l] = '\ 0'; If (L = 0) continue; For (j = 0; j <K; j ++) {If (strcmp (A [J], temp2) = 0) {B [J] ++; break ;}} if (j = K) {strcpy (A [J], temp2); B [J] ++; k ++;} l = 0 ;}} temp2 [l] = '\ 0 '; if (L = 0) continue; For (j = 0; j <K; j ++) {If (strcmp (A [J], temp2) = 0) {B [J] ++; break ;}} if (j = k) {strcpy (A [J], temp2); B [J] ++; k ++;} l = 0 ;}for (I = 0; I <K; I ++) for (j = I + 1; j <K; j ++) {If (strcmp (A [I], a [J])> 0) {strcpy (temp2, a [J]); temp3 = B [J]; strcpy (A [J], a [I]); B [J] = B [I]; strcpy (A [I], temp2 ); B [I] = temp3 ;}} printf ("% d \ n", k); for (I = 0; I <K; I ++) {printf ("% S % d \ n", a [I], B [I]) ;}} return 0 ;}