Wow! Such Doge! HDU - 4847(虽然是道水题 但很有必要记一下)
就是求出现了多少次doge 不区分大小写 巧用字符串函数
isalpha 判断是否是字母
tolower 转换为小写字母 toupper 转换为大写字母
strncmp字符串比较函数 能限制比较的长度
#include <iostream>
#include <cstdio>
#include <sstream>
#include <cstring>
#include <map>
#include <cctype>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#define rap(i, a, n) for(int i=a; i<=n; i++)
#define rep(i, a, n) for(int i=a; i<n; i++)
#define lap(i, a, n) for(int i=n; i>=a; i--)
#define lep(i, a, n) for(int i=n; i>a; i--)
#define rd(a) scanf("%d", &a)
#define rlld(a) scanf("%lld", &a)
#define rc(a) scanf("%c", &a)
#define rs(a) scanf("%s", a)
#define MOD 2018
#define LL long long
#define ULL unsigned long long
#define Pair pair<int, int>
#define mem(a, b) memset(a, b, sizeof(a))
#define _ ios_base::sync_with_stdio(0),cin.tie(0)
//freopen("1.txt", "r", stdin);
using namespace std;
const int maxn = , INF = 0x7fffffff; char s[maxn];
int cnt; int main()
{
cnt = ;
while(gets(s))
{
int len = strlen(s);
for(int i=; i<len; i++)
if(isalpha(s[i]))
s[i] = tolower(s[i]);
for(int i=; i<len; i++)
if(strncmp(s+i, "doge", ) == )
cnt++; }
cout<< cnt <<endl; return ;
}
Wow! Such Doge! HDU - 4847(虽然是道水题 但很有必要记一下)的更多相关文章
- (KMP 水)Wow! Such Doge! -- hdu -- 4847
http://acm.hdu.edu.cn/showproblem.php?pid=4847 Wow! Such Doge! Time Limit:1000MS Memory Limit:32 ...
- Wow! Such Doge! - HDU 4847 (水题)
题目大意:题目描述了一大堆.....然而并没什么用,其实就是让求给的所有字符串里面有多少个"doge",不区分大小写. 代码如下: ====================== ...
- HDU 4847 陕西邀请赛A(水)
HDU 4847 Wow! Such Doge! pid=4847" style="">题目链接 题意:给定文本,求有几个doge,不区分大写和小写 思路:水题.直 ...
- 【转】POJ百道水题列表
以下是poj百道水题,新手可以考虑从这里刷起 搜索1002 Fire Net1004 Anagrams by Stack1005 Jugs1008 Gnome Tetravex1091 Knight ...
- HDU 5578 Friendship of Frog 水题
Friendship of Frog Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.ph ...
- HDU 5590 ZYB's Biology 水题
ZYB's Biology Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid ...
- HDU 5538 L - House Building 水题
L - House Building Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.ph ...
- hdu 5104 素数打表水题
http://acm.hdu.edu.cn/showproblem.php?pid=5104 找元组数量,满足p1<=p2<=p3且p1+p2+p3=n且都是素数 不用素数打表都能过,数据 ...
- ZOJ3778--一道水题
Description As we all know, Coach Gao is a talented chef, because he is able to cook M dishes in the ...
随机推荐
- python游戏编程——乌龟和鱼类场景编程
综合举例: 游戏编程:按以下要求定义一个乌龟类和鱼类并尝试编写游戏. O 假设游戏场景为范围(x, y)为0<=x<=10,0<=y<=10 · 游戏生成1只 ...
- OpenCV Error: Assertion failed (scn == 3 || scn == 4) in cv::cvtColor
在python用cv2.imread()读取图片的时候一直报错,检查了图片的绝对路径是存在的. 报错的图片用skimage.io.imread()是可以读的. 查了一下,有可能是原图片文件有什么嵌入错 ...
- 使用request+Beautiful爬取妹子图
一.request安装 pip install requests request使用示例 import requests response = requests.get('https://www.mz ...
- xml解析数据信息并实现DBManager操作mysql
先前一直都是用的直接用加载驱动 然后创建连接进行操作数据 如果我的数据库换了 那么要修改的地方也比较多 不利于维护 所以就想到了将所有配置连接信息都用xml封装起来 以至于我每次都只要修改一下我的 ...
- linux常用命令总结(含选项参数)
• 用户切换 su 切换到root用户并不切换环境 su - root 切换到root用户并切换环境 su redhat 切换到redhat不切换环境 • cd切换目 ...
- 零基础学python之构建web应用(入门级)
构建一个web应用 前面的学习回顾: IDLE是Python内置的IDE,用来试验和执行Python代码,可以是单语句代码段,也可以是文本编辑器中的多语句程序. 四个内置数据结构:列表.字典.集合和元 ...
- Elasticsearch Java client(ES Client 简介、Java REST Client、Java Client、Spring Data Elasticsearch)
elasticsearch系列七:ES Java客户端-Elasticsearch Java client(ES Client 简介.Java REST Client.Java Client.Spri ...
- 从零开始的Python学习 知识补充sorted
sorted()方法 sorted()可用于任何一个可迭代对象. 原型为sorted(iterable, cmp=None, key=None, reverse=False) iterable:一个可 ...
- Hadoop Streaming框架使用(二)
上一篇文章介绍了Streaming的各种参数,本文具体介绍使用方法. 提交hadoop任务示例: $HADOOP_HOME/bin/hadoop streaming \ -input /user/te ...
- C++ 类的定义与实现
摘自这篇博客https://blog.csdn.net/xulingxin/article/details/81335030 一."类" 的介绍 在C++中, 用 &q ...