第五次测试 大小写转换

Eddy usually writes articles ,but he likes mixing the English letter uses, for example “computer science” is written frequently “coMpUtEr scIeNce” by him, this mistakes lets Eddy’s English teacher be extremely discontentment.Now please you to write a procedure to be able in the Bob article English letter to turn completely the small letter.
Input
The input contains several test cases.each line consists a test case,Expressed Eddy writes in an article , by letter, blank space,numeral as well as each kind of punctuation
composition, the writing length does not surpass 1000 characters.
Output
For each test case, you should output an only line, after namely the result of transforms the lowercase letter.
Sample Input
weLcOmE tO HDOj Acm 2005!
Sample Output
welcome to hdoj acm 2005!
嗯,看起来很傻逼对吧,纯英文题,作为一个英语从来不及格的爱国有志青年在看到这种题时,心里满满的草泥马,但是没办法,稍微上档次的比赛,都是英文题。看不懂就只能找翻译了。

艾迪经常写文章,但是他喜欢混用英语字母,例如“计算机科学”经常是他写的“计算机科学”,这个错误让艾迪的英语老师非常不满。现在请你写一篇程序能在鲍勃的文章中把英文字母完全变成小写字母。
**输入”
输入包含几个测试用例。每行由一个测试用例组成,表达涡流写在一篇文章中,由字母、空格、数字以及各种标点组成,写作长度不超过1000个字符
**输出
*对于每个测试用例,您应该只输出一行,即转换小写字母后的结果。

以上是我用有道翻译的结果,不可能词意通达,但大体明白题目的要求就行,示例的话应该都能看懂。
话不多说,直接贴代码

#include<stdio.h>
int main ()
{
	char a[1000];
	int i;
	while(gets(a)!=NULL)
	{ 
		int t;
		t=sizeof(a)/sizeof(a[0]);
		for(i=0;i<t;i++)
		{
			if(a[i]<='Z'&&a[i]>='A')
			{
				a[i]=a[i]+32;
			}
		}
		printf("%s\n",a);
	}
	return 0;
}

很简单的题,算是这次测试的签到题吧,也没什么好说的,只要注意一下空格就好了,用gets写入字符串以识别空格,注意一下控制多组输入多组输出的是NULL而不是EOF。

猜你喜欢

转载自blog.csdn.net/weixin_43902655/article/details/84764518
今日推荐