Eddy's mistakes解题报告

来源:互联网 发布:知乎过目不忘的名字 编辑:程序博客网 时间:2024/05/16 05:04

题目摘要:Eddy usually writes articles ,buthe likes mixing the English letter uses, for example "computerscience" is written frequently "coMpUtEr scIeNce" by him, thismistakes lets Eddy's English teacher be extremely discontentment.Now please youto write a procedure to be able in the Bob article English letter to turncompletely the small letter.

题目大意:将给出的一串字符中大写字母改成小写。

输入输出要求

Input

The input contains several test cases.eachline consists a test case,Expressed Eddy writes in an article , by letter, blank space,numeralas well as each kind of punctuation
composition, the writing length does not surpass 1000 characters.

 

Output

For each test case, you should output anonly line, after namely the result of transforms the lowercase letter.

 

输入输出样例

Sample Input

weLcOmE tO HDOj Acm 2005!

 

Sample Output

welcome to hdoj acm 2005!

 

解题思路:直接用阿斯科马值,大写字母的阿斯科马值加上32就是小写字母。

代码

#include<iostream>

#include<cstring>

#include<string>

using namespace std;

char str[1005];

int main()

{

    while(cin.getline(str,1005))

    {

        for(int i=0;i<strlen(str);i++)

        {

            if((str[i]>='A')&&(str[i]<='Z'))

                str[i]+=32;

       }

        cout<<str<<endl;

        memset(str,'\0',sizeof(str));

    }

    return 0;

}

解题感想:这题主要涉及到用C++在字符数组中输入空格,而且涉及多组样例。搞定了输入一切ok。

原创粉丝点击