Abbreviations phrase

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/qq_45499204/article/details/102759205

Title Description

Definition: A phrase in uppercase first letter of each word combination is known as an abbreviation of the phrase.
For example, C language commonly used EOF is end of file abbreviation.

Entry

The first line of the input is an integer T, T represents a total set of test data.
Then there are T rows, one row for each test, each row has a phrase, each phrase consisting of one or more words; number of words in each group is not more than 10, each word has one or more capital or lowercase letters;
the word length of not more than 10, the words separated by one or more spaces.

Export

Please abbreviation test data output for each group specified, each set of output per line.

Sample input

1
end of file

Sample Output

EOF

Code


```cpp
#include<stdio.h>
#include<iostream>
using namespace std;
int main(){
	int T;
	scanf("%d",&T);
	getchar();//
	while(T--){
	char str[200];
	gets(str);
	if(str[0]>='a' && str[0]<='z'){
		printf("%c",str[0]-32);
	} 
	else if(str[0]>='A' && str[0]<='Z'){
		printf("%c",str[0]);
	} 
	for(int i=1;str[i]!='\0';i++){
		if(str[i]==' '&& (str[i+1]>='a'&& str[i+1]<='z')){
			printf("%c",str[i+1]-32);
		}
		else	if(str[i]==' '&& (str[i+1]>='A'&& str[i+1]<='Z')){
			printf("%c",str[i+1]);
		}
	}
	printf("\n");
	}
	return 0;
}

Guess you like

Origin blog.csdn.net/qq_45499204/article/details/102759205