题目:hdu4847:Wow! Such Doge!

题目大意:在给出的段落里面找出“doge”出现的次数。大写和小写都能够。

解题思路:字符串匹配问题,能够在之前将字母都转换成统一格式。

代码:

#include <stdio.h>
#include <string.h> const int N = 1e6;
char str[N];
const char *s1 = "doge"; int find () { int sum = 0;
char *p = strstr(str, s1);
while (p != NULL) { sum++;
p = p + 4;
//if (*p == '\0')
// break; p = strstr (p, s1);
}
return sum;
} int main () { int count = 0;
while (scanf ("%s", str) != EOF) { for (int i = 0; i < strlen (str); i++)
if (str[i] >= 'A' && str[i] <= 'Z')
str[i] += 32;
count += find ();
}
printf ("%d\n", count);
return 0;
}

最新文章

  1. less简单用法
  2. 三层架构与MVC &amp;amp; 设计模式的较量
  3. 50行代码仿backbone_todos
  4. Mac运行exe的几种方法,欢迎补充!
  5. namespace的用法
  6. VBA在WORD中给表格外的字体设置为标题
  7. Android之动态图片
  8. Android程序安装后在模拟器上不显示,并且控制台显示The launch will only sync the application package on the device!
  9. 在vim保存时获得sudo权限
  10. Swift语言指南(八)--语言基础之元组
  11. linux权限解读
  12. HDU1212
  13. Akka(42): Http:身份验证 - authentication, autorization and use of raw headers
  14. CentOS6.8 安装node.js npm
  15. python机器可读数据-json
  16. 【2018.05.11 智能驾驶/汽车电子】非技术向:关于Simulink和AutoSar的几种观点
  17. 四、触发器(Trigger)
  18. Mysql 中获取刚插入的自增长id的值
  19. Asp连接Oracle (包含绿色版12.2客户端和ODBC驱动安装)
  20. oracle 配置本地Net服务

热门文章

  1. 去除自定义Toolbar中左边距
  2. 如何评价 GitHub 发布的文本编辑器 Atom?
  3. C#拦截系统消息的方法-Application.AddMessageFilter
  4. python调用top命令获得CPU利用率
  5. spring boot 引用外部配置文件
  6. 【Hadoop】HDFS冗余数据块的自动删除
  7. lua基础【三】唯一数据结构table表
  8. liunx下安装第三方Python(PIP安装)
  9. 微信小程序 - 获取用户信息的几种方式
  10. Vue笔记五