最近研究返回子串,稍微总结一下,以后继续补充:

A. Whose sentence is it?
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

One day, liouzhou_101 got a chat record of Freda and Rainbow. Out of curiosity, he wanted to know which sentences were said by Freda, and which were said by Rainbow. According to his experience, he thought that Freda always said "lala." at the end of her sentences, while Rainbow always said "miao." at the beginning of his sentences. For each sentence in the chat record, help liouzhou_101 find whose sentence it is.

Input

The first line of the input contains an integer n (1 ≤ n ≤ 10), number of sentences in the chat record. Each of the next n lines contains a sentence. A sentence is a string that contains only Latin letters (A-Z, a-z), underline (_), comma (,), point (.) and space ( ). Its length doesn’t exceed 100.

Output

For each sentence, output "Freda's" if the sentence was said by Freda, "Rainbow's" if the sentence was said by Rainbow, or "OMG>.< I don't know!" if liouzhou_101 can’t recognize whose sentence it is. He can’t recognize a sentence if it begins with "miao." and ends with "lala.", or satisfies neither of the conditions.

Sample test(s)
input
5
I will go to play with you lala.
wow, welcome.
miao.lala.
miao.
miao .

output
Freda's
OMG>.< I don't know!
OMG>.< I don't know!
Rainbow's
OMG>.< I don't know!

每日一道理
我拽着春姑娘的衣裙,春姑娘把我带到了绿色的世界里。

strstr(s,p)   //在s中找p,返回指向第一个子串首的指针,若无返回NULL.

gets(s)    //读入一行.

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<cctype>
using namespace std;
#define For(i,n) for(int i=1;i<=n;i++)
#define Rep(i,n) for(int i=0;i<n;i++)
#define Fork(i,k,n) for(int i=k;i<=n;i++)
#define ForD(i,n) for(int i=n;i;i--)
#define Forp(x) for(int p=pre[x];p;p=next[p])
#define RepD(i,n) for(int i=n;i>=0;i--)
int n;
char s[1000+10],p1[10]="miao.",p2[10]="lala.";
int main()
{
//  freopen("CF312A.in","r",stdin);
//  freopen(".out","w",stdout);scanf("%d",&n);gets(s);while (n--){gets(s);int len=strlen(s);bool b1=(strstr(s,p1))==s,b2=(strstr(s+strlen(s)-strlen(p2),p2)==(s+strlen(s)-strlen(p2)));if (!(b1^b2)) puts("OMG>.< I don't know!"); else if (b1) puts("Rainbow's");else puts("Freda's");   }return 0;
}

文章结束给大家分享下程序员的一些笑话语录: 腾讯的动作好快,2010年3月5日19时28分58秒,QQ同时在线人数1亿!刚刚看到编辑发布的文章,相差才2分钟,然后连专题页面都做出来了,他们早就预料到了吧?(其实,每人赠送10Q币,轻轻松松上两亿!)

--------------------------------- 原创文章 By
返回和子串
---------------------------------

返回子串CF 312A(Whose sentence is it?-strstr(s,p))相关推荐

  1. Netfilter实验

    Netfilter netfilter是linux内的一个子系统,其提供了一系列检查点,用户可以编写对数据包的处理函数,并将函数注册在某一个检查点上.当数据包到达时,系统将调用该函数对数据包进行处理, ...

  2. python中用来返回序列的最大函数_Python程序设计2——列表和元组

    数据结构:更好的说法是从数据角度来说,结构化数据,就是说数据并不是随便摆放的,而是有一定结构的,这种特别的结构会带来某些算法上的性能优势,比如排序.查找等. 在Python中,最基本的数据结构是序列( ...

  3. leetcode--最长回文子串--python

    文章目录 题目 题目详情 示例 解题思路 思路 代码 运行结果 最佳方案 题目 题目详情 给定一个字符串 s,找到 s 中最长的回文子串.你可以假设 s 的最大长度为 1000. 示例 输入: &qu ...

  4. C语言经典例96-计算字符串中子串出现的次数

    目录 1 题目 2 分析 3 实现 4 运行结果 1 题目 计算字符串中子串出现的次数 2 分析 串的模式匹配在数据结构中有KMP算法,但这个算法实现起来繁琐,难度很大,所以对于一般来说,使用暴力法求 ...

  5. 【C 语言】字符串模型 ( strstr-while 模型 | 抽象函数模型 | 业务子函数接口定义要点 | 形参指针间接赋值 | 返回值状态 | 形参指针处理 | 形参指针判空 | 形参返回值 )

    文章目录 前言 一.业务子函数接口定义要点 二.完整代码示例 前言 字符串开发模型 : strstr-while/do-while 模型 : 在 字符串 中 查找 子串特征 ; 两头堵模型 : 两个指 ...

  6. 51Nod-2149子串水题find

    2149 字符串出现位置 题目链接:https://www.51nod.com/Challenge/Problem.html#problemId=2149 1.0 秒 131,072.0 KB 5 分 ...

  7. 【C++】35.判断一个文件是否存在、 查找字符串中的子串

    1.判断一个文件是否存在,IsFileExists() bool IsFileExists(const std::string &file_name) {std::ifstream fin(f ...

  8. python截取子串_python获得子串

    广告关闭 腾讯云11.11云上盛惠 ,精选热门产品助力上云,云服务器首年88元起,买的越多返的越多,最高返5000元! python很适合完成这种文本处理任务,字符串重复判断这种任务可以使用dict来 ...

  9. 实验11.1 指针数组、指针与函数 6-5 查找子串

    本题要求实现一个字符串查找的简单函数. 函数接口定义: char *search( char *s, char *t ); 函数search在字符串s中查找子串t,返回子串t在s中的首地址.若未找到, ...

最新文章

  1. 布隆过滤器 redis_使用基于 Redis 的 Java 布隆过滤器
  2. 尺度不变特征变换匹配算法详解 Scale Invariant Feature Transform(SIFT)
  3. 一文看懂计算机视觉-CV(基本原理+2大挑战+8大任务+4个应用)
  4. 列举5个python内置函数_Python5个内建高阶函数的使用
  5. 在sql中将表建在别的构件中用什么语句_SQL实战
  6. 【华为云技术分享】云小课 | SAP S/4HANA高可用之实战演练
  7. .NET解决[Serializable] Attribute引发的Json序列化k_BackingField
  8. 树桩数组求逆序数+离散化(数太大)
  9. Code Snippet 插件 使用——代码高亮
  10. 计算机在现代设计技术中应用,计算机技术在现代建筑设计中的应用
  11. IDEA 更换主题样式
  12. 新一配:iTunes的历史版本【转载】
  13. Windows自建虚拟机搭建kms激活服务器激活正版系统教程
  14. kafka和ZK的关系
  15. PXE网络安装linux系统
  16. 横向时间轴插件 html5,jQuery横向滚动时间轴插件
  17. matlab2018a课后答案,[2018年最新整理]matlab习题及答案.doc
  18. 【Vue】pc和移动端网页样式适配
  19. 苹果三代耳机_p360 AirPods Pro 苹果三代耳机
  20. 手机网站支付(公钥证书方式)

热门文章

  1. 如何安装jdk_Java JDK下载与安装教程
  2. django html5 video,Django Web中的静态文件之HTML5第1篇
  3. 批量 杀掉 mysql 连接_批量杀死MySQL连接的四种方法详解
  4. 基于 RT-Thread的全向赛车算法开发
  5. 自制pyBoard的I2C实验,应用MicroPython
  6. 第十五届全国大学生智能汽车竞赛创意组比赛进入全国总决赛队伍名单
  7. android小程序案例_这几个小程序案例告诉你,小程序该怎么做!
  8. css通配选择符用什么表示,css的选择符
  9. java map 结构体_业务代码的救星——Java 对象转换框架 MapStruct 妙用
  10. 今日工作总结 2022-02-08