2020牛客暑期多校训练营(第三场)L

Problem L is the Only Lovely Problem

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).

示例1

输入

LovelyAA

输出

lovely

示例2

输入

lovelymoon

输出

lovely

示例3

输入

NOWCOWDER

输出

ugly

示例4

输入

LoveLive

输出

ugly

分析

  要求字符串开头为 "lovely",只需要依次比较字符串开头的六位即可,只需要注意比较是不区分大小写的。

代码

/******************************************************************
Copyright: 11D_Beyonder All Rights Reserved
Author: 11D_Beyonder
Problem ID: 2020牛客暑期多校训练营(第三场) Problem L
Date: 8/14/2020
Description: Easy String Problem
*******************************************************************/
#include<iostream>
#include<string>
#include<cstdio>
using namespace std;
int main(){
    string s;
    cin>>s;
    //依次比较6位
    //不区分大小写
    if((s[0]=='l'||s[0]=='L')&&
    (s[1]=='o'||s[1]=='O')&&
    (s[2]=='v'||s[2]=='V')&&
    (s[3]=='e'||s[3]=='E')&&
    (s[4]=='l'||s[4]=='L')&&
    (s[5]=='y'||s[5]=='Y')){
        puts("lovely");
    }else{
        puts("ugly");
    }
    return 0;
}
牛客暑期多校训练营题解 文章被收录于专栏

收集牛客暑期多校训练营的题解

全部评论

相关推荐

2025-12-28 16:32
重庆邮电大学 Java
程序员花海:1.技能放最后,来面试默认你都会,技能没啥用 2.实习写的看起来没啥含金量,多读读部门文档,包装下 接LLM这个没含金量 也不要用重构这种 不会给实习生做的 3.抽奖这个还是Demo项目,实际在公司里面要考虑策略,满减,触发点,触发规则 库存 之类的,不是这个项目这么简单 4.教育背景提前,格式为 教育背景 实习 项目 技能 自我评价
简历被挂麻了,求建议
点赞 评论 收藏
分享
01-11 08:47
门头沟学院 Java
choumoduji...:读研的目的就是为了以最快的速度和最低的要求完成“学校”规定的毕业标准,而不是所谓课题组的要求
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务