牛客多校(2020第三场)L Problem L is the Only Lovely Problem

题目链接:https://ac.nowcoder.com/acm/contest/5668/L

题意:判断一个字符串是否lovely开头,不分大小写

题解:将字符串全部换成小写字母,判断该字符串开头是否未lovely

 1 #include<iostream>
 2 #include<string>
 3 #include<algorithm>
 4 using namespace std;
 5 
 6 int main() {
 7     string s;
 8     cin >> s;
 9     transform(s.begin(),s.end(),s.begin(),::tolower);
10     string t = s.substr(0,6); 
11     if(t == "lovely")  cout<<"lovely"<<endl;
12     else               cout<<"ugly"<<endl;
13     return 0;
14 }

 

posted @ 2020-08-19 10:31  Mr__wei  阅读(31)  评论(0编辑  收藏  举报