P9712 「QFOI R1」贴贴 题解

· · 题解

  1. 输出 solution-

  2. 将字符串扫一遍,当为下划线时转化为减号。

  3. tolower 可把所有字母转小写。

最终输出字符串即可。

代码如下:

#include<bits/stdc++.h>
using namespace std;

signed main()
{
    string st;
    cin>>st;
    cout<<"solution-";
    for(int i=0;i<st.size();i++){
        if(st[i]=='_')st[i]='-';
        st[i]=tolower(st[i]);
    }
    cout<<st;
}