Problem description Definition: The capitalization combination of the first letter of each word in a phrase is called the abbreviation of the phrase.
For example, the usual EOF in C is the end of the file abbreviation.
The first line of input inputs is an integer t representing a total of T-group test data;
Next there is T line, each group of test data for a row, each line has a phrase, each phrase consists of one or more words, each group of words not more than 10, each word has one or more uppercase or lowercase letters;
The word length does not exceed 10, and the words are separated by one or more spaces.
Output specify the abbreviations for each set of test data, one row for each set of outputs.
Sample Input1end of File
Sample outputeof
Things to consider: ASD asdasd ASD ASD
1#include <stdio.h>2#include <math.h>3#include <queue>4#include <vector>5#include <stack>6#include <map>7#include <string>8#include <string.h>9#include <algorithm>Ten#include <iostream> One using namespacestd; A Charstr[ +],s[ +]; - intMain () - { the intT; -scanf"%d%*c",&t); - while(t-- ) - { + gets (str); - inti =0, C =0; + while(Str[i]) A { at if( !Isalpha (Str[i])//If the input character is an English letter, that is a-Z or a-Z, returns a value other than 0 (depending on how much depends on the system implementation), otherwise returns 0. - { -++i; - Continue; - } - if(Str[i] >'Z' ) inStr[i]-= +; -S[c++] =Str[i]; to while(Isalpha (Str[i])) +++i; - } theS[C] =0; * puts (s); $ }Panax Notoginseng return 0; -}
Decomposition:
1#include <stdio.h>2#include <stdlib.h>3#include <string.h>4 Chara[ -],b[ -];5 intMain ()6 {7 intT;8 inti;9 intlen=0;Ten intK; Onescanf"%d",&T); A GetChar (); - while(t--) - { the gets (a); -len=strlen (a); - STRUPR (a); -k=0; + for(i=0; i<len;i++) - { + if(i==0) A { at if(a[i]==' '&& a[i+1]!=' ') -b[k++]=a[i+1]; - Else if(a[i]!=' ') -b[k++]=A[i]; - } - Else in { - if(a[i]==' '&& a[i+1]) tob[k++]=a[i+1]; + } - } the for(i=0; i<k;i++) * { $ if(b[i]!=' ')Panax Notoginsengprintf"%c", B[i]); - } theprintf"\ n"); + } A return 0; the}
Phrase abbreviation (Application of Isalpha ())