WOJ1340-Easy or Hard

This is the Fifth Problem in this contest. Maybe this is not an easy one, but I think you are clever enough to solve it. Try your best! 

As is known to all, most people's name can be divided into two part, one part is the family name and the other part is the given name. In Chinese we write family name before given name, but in English we write the given name first. Now the task is below: 
Given N names written in Chinese Type, you should change them into English Type. 

输入格式

In the first line, there is an Integer N(1<=N<=1000), which means there are N test cases in the problem.
There are N lines followed, each contains two strings and the total length of them is less than 200. The first one is the family name and the second one is the given name.

输出格式

For each test case, you should output a line contains two strings with a space character between them, the first one is the given name and the second one is the family name. What's more, we all know that the first character of the family name and the given name should be an uppercase one and other characters should be a lowercase one, so if there are mistakes in the strings, you must correct them.

样例输入

3
Zhang Wei
Wang LiangJing
Zhou Chen

样例输出

Wei Zhang
Liangjing Wang
Chen Zhou


#include<stdio.h>
#include<string.h>
int main(){
    int i,t,j,l,n;
    scanf("%d",&t);
    char name[2][200];
    for(i=0;i<t;i++){
    	scanf("%s %s",&name[0],&name[1]);
    	for(j=0;j<2;j++){
    		l=strlen(name[j]);
    		n=0;
    		while(n<l){
    			if((n==0)&&(name[j][0]>='a')&&(name[j][0]<='z'))
    			name[j][0]-=32;
    			else if((n>0)&&(name[j][n]>='A')&&(name[j][n]<='Z'))
				name[j][n]+=32;
				n++;
			}
		}
		printf("%s %s\n",name[1],name[0]);
	}
	return 0;
}


全部评论

相关推荐

不愿透露姓名的神秘牛友
07-09 12:11
点赞 评论 收藏
分享
每晚夜里独自颤抖:要求太多的没必要理
点赞 评论 收藏
分享
fRank1e:吓得我不敢去外包了,但是目前也只有外包这一个实习,我还要继续去吗
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务