Eddy's mistakes HDU

链接

[http://acm.hdu.edu.cn/showproblem.php?pid=1161]

题意

把字符串中大写字母变为小写 。

分析

主要是含有空格的字符串如何读入,用getline(cin,s);

代码

#include<iostream>
#include<string>
using namespace std;
#define ll long long
int main(){
    
    //freopen("in.txt","r",stdin);
    string s;
    while(getline(cin,s)){
        int i;
        for(i=0;i<s.length();i++)
        {
            if(s[i]>='A'&&s[i]<='Z')
            cout<<char(s[i]+32);
           else cout<<s[i];
        }
        cout<<endl;
    }
    return 0;
}

猜你喜欢

转载自www.cnblogs.com/mch5201314/p/9803485.html