Home > Back-end >  Abbreviation of the Word novice problem for error correction
Abbreviation of the Word novice problem for error correction

Time:10-04

#include
#include
Int jud (char STR [])
{
int i;
STR=strupr (STR);
If (strlen (STR) & lt; 3 & amp; & Strlen (STR)!=0)
return -1;
Else if (strlen (STR)==3)
{
for(i=0; i{
If (STR [I]=='A' & amp; & STR [I + 1)=='N' & amp; & STR [I + 2]=='D')
return -1;
Else if (STR [I]=='F' & amp; & STR==[I + 1] 'O' & amp; & STR [I + 2]=='R')
return -1;
Else if (STR [I]=='T' & amp; & STR [I + 1)=='H' & amp; & STR [I + 2]=='E')
return -1;
The else
return 1;
}
}
The else
return 1;

}
Int main ()
{
Int I=0, n, a=0, b=0, c, len.
Char s [1000], [1000] s1.
Char STR [30].
The scanf (" % d ", & amp; N);
getchar();
While (i{
Gets (s);
Len=strlen (s);
for(a=0; A{
If (s [a]!=' ')
{
STR [a] [b]=s;
B++;
}
Else if (s [a]==' ')
{
If (b!=0)
{
C=jud (STR);
If (c==1)
{printf (" % c ", STR [0]). }
}
Memset (STR, 0, sizeof (STR));
B=0;
}
}
C=jud (STR);
If (c==1)
Printf (" % c \ n ", STR [0]).
The else
printf("\n");
Memset (STR, 0, sizeof (STR));
B=0;
I++;
}
Return 0;
}


Input: 1
A for a
Output: A
There is no output had asked
Attached to the topic:
As we know, we often use a short sequence of characters in place of some words with a very long name. For example, ACM is an abbreviation of "Association for Computing Machinery". Now we are using an acronymic method to get the abbreviation. An acronym is generated from a long name by capitalizing the first letter of every word in the name and concatenating them together. There is an exception: some words are ignored when generating the abbreviation. These words( case insensitive) meet the following rules: 1. The common words "and", "for", and "the". 2. The words with length less than 3, such as "a", "of", "to". Your job is to get the abbreviation of a given string by using the acronymic method.

Input
The Input starts with an integer T (T & lt;=100), denoting the number of test cases. Each case contains a line with several words seperated by space (s). The length of Each line is less than 100. And you can assume that there is an at further one available word for Each case.

The Output
For each case, print the abbreviation of the word.

The Sample Input
5
Online Judge
Association for Computer Machinery
Institute of Electrical and Electronics Engineers
The Lord of The Rings
Ningbo


The Sample Output
OJ
ACM
The IEEE
LR
N

CodePudding user response:

  • Related