Flymouse's English is very poor. Therefore, he always makes some mistakes in his composition.
For example, in sentence "flymouse is poor in EnGlish but his girlfriend is good at English" are there two mistakes:
1. Initial letter f of the first word flymouse of this sentence is not a capital letter.
2. EnGlish's medial letter G is a capital letter.
Notice this, you can correct the mistake by the following two steps:
1. Make the initial letter of the first word of the sentence to be capital.
2. Make the non-initial letters of the non-first words of the sentence to be small.
You can assure that by doing this, the new sentence will be always a correct one.
For this sample, the correct form is:
Flymouse is poor in English but his girlfriend is good at English
输入格式
The first line contains a single integer t, indicating the number of test cases, followed by one line for each test case. The line for each test case contains a sentence from flymouse's composition. the length of the sentence will be not larger than 10000. For simplicity, punctuations will always be omitted.
输出格式
There should be one output line per test case containing the correct sentence.
样例输入
1 flymouse is poor in EnGlish but his girlfriend is good at English
样例输出
Flymouse is poor in English but his girlfriend is good at English
#include<stdio.h>
#include<string.h>
char s[10010];
int t;
int main(){
int state,i,len;
scanf("%d",&t);
getchar();
while(t--){
gets(s);
len=strlen(s);
state=0;
for(i=0;i<len;i++){
if(i==0){
if(s[i]>='a'&&s[i]<='z')
s[i]=s[i]-'a'+'A';
}else if(s[i]==' '){
state=1;
i++;
}else if(s[i]>='A'&&s[i]<='Z')
s[i]=s[i]-'A'+'a';
}
printf("%s\n",s);
}
return 0;
}