Loading [MathJax]/jax/input/TeX/config.js
前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >【HDU 5007】Post Robot

【HDU 5007】Post Robot

作者头像
饶文津
发布于 2020-05-31 15:39:06
发布于 2020-05-31 15:39:06
51100
代码可运行
举报
文章被收录于专栏:饶文津的专栏饶文津的专栏
运行总次数:0
代码可运行

Description

DT is a big fan of digital products. He writes posts about technological products almost everyday in his blog.  But there is such few comments of his posts that he feels depressed all the day. As his best friend and an excellent programmer, DT asked you to help make his blog look more popular. He is so warm that you have no idea how to refuse. But you are unwilling to read all of his boring posts word by word. So you decided to write a script to comment below his posts automatically.  After observation, you found words “Apple” appear everywhere in his posts. After your counting, you concluded that “Apple”, “iPhone”, “iPod”, “iPad” are the most high-frequency words in his blog. Once one of these words were read by your smart script, it will make a comment “MAI MAI MAI!”, and go on reading the post.  In order to make it more funny, you, as a fan of Sony, also want to make some comments about Sony. So you want to add a new rule to the script: make a comment “SONY DAFA IS GOOD!” when “Sony” appears. 

Input

A blog article described above, which contains only printable characters(whose ASCII code is between 32 and 127), CR(ASCII code 13, ‘\r’ in C/C++), LF(ASCII code 10, ‘\n’ in C/C++), please process input until EOF. Note all characters are case sensitive.  The size of the article does not exceed 8KB.

Output

Output should contains comments generated by your script, one per line.

Sample Input

Apple bananaiPad lemon ApplepiSony

233

Tim cook is doubi from Apple

iPhoneipad

iPhone30 is so biiiiiiig Microsoft

makes good App.

Sample Output

MAI MAI MAI!

MAI MAI MAI!

MAI MAI MAI!

SONY DAFA IS GOOD!

MAI MAI MAI!

MAI MAI MAI!

MAI MAI MAI!

题意:每行中有“Apple”, “iPhone”, “iPod”, “iPad” 出现则,输出MAI MAI MAI!,有Sony出现,输出SONY DAFA IS GOOD!

分析:读入用字符串读,然后用strstr函数,strstr(str1,str2)返回字符串str2在str1第一次出现的指针

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
#include<stdio.h>
#include<string.h>
char str[10240],ch[10][10]={"Apple", "iPhone", "iPod", "iPad" ,"Sony"};
int main(){
    while(~scanf("%s",str)){
        for(int i=0;i<4;i++)
            if(strstr(str,ch[i])-str>=0)
                printf("MAI MAI MAI!\n");
        if(strstr(str,ch[4])-str>=0)
            printf("SONY DAFA IS GOOD!\n");
    }
    return 0;
}
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2016-02-05 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
暂无评论
推荐阅读
编辑精选文章
换一批
Buzzcast_buzz killer
Episode 49 of The SitePoint Podcast is now available! This week your hosts are Stephan Segraves (@ssegraves), Brad Williams (@williamsba), and Kevin Yank (@sentience).
全栈程序员站长
2022/11/04
1.6K0
Data Structures and Algorithms Basics(017):String
# 1,偶数子串的数量: def evenNum(s): count = 0 for i in range(len(s)): if int(s[i]) % 2 == 0: count += i + 1 return count if __name__ == '__main__': evenNum("1234") # 2,出勤记录: def checkRecord(self, s): return not (s.count('A
用户5473628
2019/08/08
5160
你写的字符(串)忽略大小写比较函数真的严谨吗?
有时我们比较两个字符串时不考虑它们是大写还是小写;举个例子,在这种情况下我们认为“BanAna”和“baNaNA”是等价的。
xiaoxi666
2018/10/29
1.3K0
【C语言 字符函数和字符串函数】—— 文本数据的奇幻加工坊,代码世界的魔法编织者
在学习字符和字符串函数之前,我们先认识一下ASCLL码,ASCII 编码是字符处理的基础,了解其规则对编程非常重要!
换一颗红豆
2024/12/23
2790
【C语言 字符函数和字符串函数】—— 文本数据的奇幻加工坊,代码世界的魔法编织者
HDOJ/HDU 1075 What Are You Talking About(字符串查找翻译~Map)
Problem Description Ignatius is so lucky that he met a Martian yesterday. But he didn’t know the language the Martians use. The Martian gives him a history book of Mars and a dictionary when it leaves. Now Ignatius want to translate the history book into
谙忆
2021/01/21
3770
HDU 1075 字典树 字符串匹配
Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 102400/204800 K (Java/Others) Total Submission(s): 11683    Accepted Submission(s): 3737
csxiaoyao
2019/02/18
5180
HDU - 1501 Zipper(dp&深搜)
Given three strings, you are to determine whether the third string can be formed by combining the characters in the first two strings. The first two strings can be mixed arbitrarily, but each must stay in its original order. For example, consider forming "tcraete" from "cat" and "tree": String A: cat String B: tree String C: tcraete As you can see, we can form the third string by alternating characters from the two strings. As a second example, consider forming "catrtee" from "cat" and "tree": String A: cat String B: tree String C: catrtee
天道Vax的时间宝藏
2021/08/11
1880
PHP基本语法快速入门
Perl的和Ruby的语法组织得非常好,于是PHP也跟着尝试将这两种语言的优势引入。
Enjoy233
2019/03/05
1.9K0
HDOJ(HDU) 4847 Wow! Such Doge!(doge字符统计)
Chen, Adrian (November 7, 2013). “Doge Is An Ac- tually Good Internet Meme. Wow.”. Gawker. Retrieved November 22, 2013.
谙忆
2021/01/21
5930
HDOJ(HDU)  4847 Wow! Such Doge!(doge字符统计)
博客世界最受欢迎的30个插件
翻译于:TOP 30 Wordpress Plugins in Blogosphere,
Denis
2023/04/13
5520
HDU 1247 字典树 拆分单词
Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 6381    Accepted Submission(s): 2378
csxiaoyao
2019/02/18
5310
Codeforces Round #256 (Div. 2/B)/Codeforces448B_Suffix Structures(字符串处理)
给两字符串,推断第一个字符串是怎么变到第二个字符串。
全栈程序员站长
2022/07/12
2140
C语言从入门到实战——常用字符函数和字符串函数的了解和模拟实现
字符函数是用来处理单个字符的函数,比如查找、替换、转换大小写、比较等操作。常用的字符函数包括:
鲜于言悠
2024/03/20
2410
C语言从入门到实战——常用字符函数和字符串函数的了解和模拟实现
HDOJ/HDU 1062 Text Reverse(字符串翻转~)
Problem Description Ignatius likes to write words in reverse way. Given a single line of text which is written by Ignatius, you should reverse all the words and then output them.
谙忆
2021/01/21
4150
算法:字符串
在示例代码中,str是一个字符串的变量名称,hello world则是该字符串的值,字符串的长度为11,该字符串的表示如下图所示:
用户3578099
2022/03/15
2.8K0
算法:字符串
hdu 3336 Count the string(kmp应用)
It is well known that AekdyCoin is good at string problems as well as number theory problems. When given a string s, we can write down all the non-empty prefixes of this string. For example: s: “abab” The prefixes are: “a”, “ab”, “aba”, “abab” For each prefix, we can count the times it matches in s. So we can see that prefix “a” matches twice, “ab” matches twice too, “aba” matches once, and “abab” matches once. Now you are asked to calculate the sum of the match times for all the prefixes. For “abab”, it is 2 + 2 + 1 + 1 = 6. The answer may be very large, so output the answer mod 10007.
全栈程序员站长
2022/09/15
2160
C语言函数小集合
一、字符操作 函数名: fputc 功 能: 送一个字符到一个流中 用 法: int fputc(int ch, FILE *stream); 函数名: fputs 功 能: 送一个字符串到一个流中 用 法: int fputs(char *string, FILE *stream); 函数名: sprintf 功 能: 输出数据到一字符串中(而printf是输出到屏幕上) 函数名: fread 用 法: fread(fa,4,5,fp); 功 能: 其意义是从fp所指的文件中,每次读4个字节(一个实数)送入实数组fa中,连续读5次,即读5个实数到fa中 函数名: strncmp 用 法: extern int strncmp(char *s1, char *s2, int n); 功 能: 比较字符串s1和s2的前n个字符。 详 细: 逐次比较两个字符串前n个字符中的每一个字符(用第一个字符串的字符的ASCII值减去第二个字符串的相应字符的ASCII值),如果相等则继续比较下一个;如果不等,ASCII的差值就是返回值。 函数名: isalnum 原型:extern int isalnum(int c); 用法:#include <ctype.h>  功能:判断字符c是否为字母或数字  说明:当c为数字0-9或字母a-z及A-Z时,返回非零值,否则返回零。 函数名: isalpha 原型:extern int isalpha(int c); 用法:#include <ctype.h> 功能:判断字符c是否为英文字母 说明:当c为英文字母a-z或A-Z时,返回非零值,否则返回零。 函数名: iscntrl 原型:extern int iscntrl(int c); 用法:#include <ctype.h> 功能:判断字符c是否为控制字符 说明:当c在0x00-0x1F之间或等于0x7F(DEL)时,返回非零值,否则返回零。 函数名: isdigit 原型:extern int isdigit(int c); 用法:#include <ctype.h> 功能:判断字符c是否为数字 说明:当c为数字0-9时,返回非零值,否则返回零。 函数名: islower 原型:extern int islower(int c); 用法:#include <ctype.h> 功能:判断字符c是否为小写英文字母 说明:当c为小写英文字母(a-z)时,返回非零值,否则返回零。 函数名: isascii 原型:extern int isascii(int c); 用法:#include <ctype.h> 功能:判断字符c是否为ascii码 说明:当c为ascii码时,返回非零值,否则返回零。ascii码指0x00-0x7F之间的字符 函数名: isgraph 原型:extern int isgraph(int c); 用法:#include <ctype.h> 功能:判断字符c是否为除空格外的可打印字符 说明:当c为可打印字符(0x21-0x7e)时,返回非零值,否则返回零。 函数名: isprint 原型:extern int isprint(int c); 用法:#include <ctype.h> 功能:判断字符c是否为可打印字符(含空格) 说明:当c为可打印字符(0x20-0x7e)时,返回非零值,否则返回零。 函数名: ispunct 原型:extern int ispunct(int c); 用法:#include <ctype.h> 功能:判断字符c是否为标点符号 说明:当c为标点符号时,返回非零值,否则返回零。 标点符号指那些既不是字母数字,也不是空格的可打印字符。 函数名: isspace 原型:extern int isspace(int c); 用法:#include <ctype.h> 功能:判断字符c是否为空白符 说明:当c为空白符时,返回非零值,否则返回零。 空白符指空格、水平制表、垂直制表、换页、回车和换行符。 函数名: isupper 原型:extern int isupper(int c);  用法:#include <ctype.h>  功能:判断字符c是否为大写英文字母 说明:当c为大写英文字母(A-Z)时,返回非零值,否则返回零。 函数名: isxdigit 原型:extern int isxdigit(int c); 用法:#include <ctype.h> 功能:判断字符c是否为十六进制数字 说明:当c为A-F,a-f或0-9之间的十六进制数字时,返回非零值,否则返回零。 函数名: toascii 原型:extern int toascii(int c);
阳光岛主
2019/02/19
1.3K0
苹果M1支点:迈向真实的扭曲领域
上周,苹果宣布将从x86部分转移到ARM上,因为其中一项声明太离谱了,它可能只来自苹果。
柴艺
2020/12/18
4290
HDOJ/HDU 1113 Word Amalgamation(字典顺序~Map)
Problem Description In millions of newspapers across the United States there is a word game called Jumble. The object of this game is to solve a riddle, but in order to find the letters that appear in the answer it is necessary to unscramble four words. Your task is to write a program that can unscramble words.
谙忆
2021/01/21
2940
第二十二章 : 格式化输出
In this chapter, we continue our look at text related tools, focusing on programs that areused to format text output, rather than changing the text itself. These tools are often usedto prepare text for eventual printing, a subject that we will cover in the next chapter. Theprograms that we will cover in this chapter include:
砖业洋__
2023/05/06
3020
相关推荐
Buzzcast_buzz killer
更多 >
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
本文部分代码块支持一键运行,欢迎体验
本文部分代码块支持一键运行,欢迎体验