链接:https://ac.nowcoder.com/acm/contest/5668/L
来源:牛客网
题目描述:
Dreamoon loves lovely things, like lovely girls, lovely bed sheets, lovely clothes...
So he thinks a string is lovely if and only if it begins with the word "lovely"(case insensitive). You are given a string. Please tell us whether Dreamoon thinks that string is lovely.
输入描述:
The input contains only one line.
This line contains a string . The length of
is between
and
.
consists of only the English alphabet. It can be lower case or upper case.
输出描述:
If a string is lovely, please output "lovely", Otherwise, output "ugly". (The output is case sensitive).
solution:
题意:给你一个字符串,如果前面几个字符是lovely(大小写都可),那么是lovely的,否者ugly
#include<iostream> #include<vector> #include<string.h> #include<stack> #include<cstdio> using namespace std; typedef long long ll; #define INF 0x3f3f3f3f string s,s1="lovely",s2="LOVELY"; int main() { cin>>s; int flag=1; if(s.length()<6) flag=0; if(flag) { for(int i=0;i<6;i++) { if(s[i]==s1[i]||s[i]==s2[i])continue; flag=0; break; } } if(flag==0) cout<<"ugly"; else cout<<s1; return 0; }