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;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值