Description
There is a list, but when you read it, it feels dizzy. Is this a list? All strings are strings without spaces. Now, you need to know whether every name in this list may exist ...... (Check whether spelling is correct)
The specific check method is as follows:
You have a dictionary that contains two parts: the last name and the first name;
You can select one from the two parts to connect them to a "string"-because there is no space on the "list" string! What's more, each word in the dictionary is capitalized (the name is like this), but this "list" does not exist, all of which are lowercase letters!
Well, if any combination appears in the "list", the name in the "list" is valid.
Now you want to check the entire list. If all the items are valid, the output value is 0;
Otherwise, an invalid "name" Q is output, and an invalid "name" is output for each row in the following Q rows ";
The output order is in the order of names in the input "list;
-
Input
-
The first line of the input contains an integer, indicating that there are N "names" that need to be checked;
Each line in the following n rows contains a string, indicating that the n names are composed of lowercase letters without spaces;
The next line contains two integers, p and q, indicating the total number of words in the last name and name of the dictionary respectively;
The following p and q lines give the p + q words respectively, and remember that the first letter is uppercase;
-
Output
-
Output according to the requirements of the topic description;
Simulation questions
# Include <stdio. h> # include <string. h> main () {int number; int I, m, n; Int J, K, flag, Count, up; char a [10000] [500]; char Xing [1000] [500]; char Ming [1000] [500]; char temp [1000]; int correct [1000]; scanf ("% d ", & number); for (I = 0; I <number; I ++) {scanf ("% s", & A [I]);} scanf ("% d", & M, & N); for (I = 0; I <m; I ++) {scanf ("% s ", & Xing [I]); Xing [I] [0] + = 32 ;}for (I = 0; I <n; I ++) {scanf ("% s", & Ming [I]); Ming [I] [0] + = 32;} up = 0; for (I = 0; I <number; I ++) {f Lag = 1; Count = 1; for (j = 0; j <m; j ++) {for (k = 0; k <n; k ++) {strcpy (temp, Xing [J]); strcat (temp, Ming [k]); If (strcmp (temp, a [I]) = 0) {flag = 0; Count = 0; break;} elsecontinue;} If (flag = 0) break;} If (count! = 0) {correct [Up] = I; up ++;} If (up = 0) printf ("0 \ n "); else {printf ("% d \ n", up); for (I = 0; I <up; I ++) printf ("% s \ n ", A [correct [I]);}