http://acm.hdu.edu.cn/showproblem.php?pid=5007

纯粹的联系String的substr

什么时候substr拦截比写短话

string te;
int n;
te="Hellow";
cout << te.substr(3,5);

我试了下 打印出来的是low....

写的时候没去限制边界还是AC了

//#pragma comment(linker, "/STACK:102400000,102400000")
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <map>
#include <set>
#include <queue>
using namespace std; #define ls(rt) rt*2
#define rs(rt) rt*2+1
#define ll long long
#define ull unsigned long long
#define rep(i,s,e) for(int i=s;i<e;i++)
#define repe(i,s,e) for(int i=s;i<=e;i++)
#define CL(a,b) memset(a,b,sizeof(a))
#define IN(s) freopen(s,"r",stdin)
#define OUT(s) freopen(s,"w",stdout)
const ll ll_INF = ((ull)(-1))>>1;
const double EPS = 1e-8;
const double pi = acos(-1.0);
const int INF = 100000000; int main()
{
string s;
while(cin>> s )
{
int len=s.size();
for(int i=0;i<len;i++)
{
string s4=s.substr(i,4);
string s5=s.substr(i,5);
string s6=s.substr(i,6);
if(s4 == "iPod" || s4 == "iPad" || s5 == "Apple" || s6=="iPhone")
puts("MAI MAI MAI!");
if(s4 == "Sony")
puts("SONY DAFA IS GOOD!");
}
}
return 0;
}

版权声明:本文博主原创文章,博客,未经同意不得转载。

hdu 5007 水 弦的更多相关文章

  1. hdu 5007 水题 (2014西安网赛A题)

    题意:出现Apple.iPod.iPhone.iPad时输出MAI MAI MAI!,出现Sony,输出SONY DAFA IS GOOD! Sample InputApple bananaiPad ...

  2. HDU-1042-N!(Java大法好 &amp;&amp; HDU大数水题)

    N! Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total Subm ...

  3. hdu - 5007 Post Robot (水题)

    http://acm.hdu.edu.cn/showproblem.php?pid=5007 #include<iostream> #include<stdio.h> #inc ...

  4. HDU 5007 Post Robot KMP (ICPC西安赛区网络预选赛 1001)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5007 解题报告:输入一篇文章,从头开始,当遇到 “Apple”, “iPhone”, “iPod”, ...

  5. hdu 4464 水

    http://acm.hdu.edu.cn/showproblem.php?pid=4464 现场赛总会有水题,这就是最水的一道,预计也就是能当高校的上机题,保研用,呵呵~~~ #include &l ...

  6. hdu 5007

    http://acm.hdu.edu.cn/showproblem.php?pid=5007 字符串处理 暴力 #include <cstdio> #include <cstdlib ...

  7. HDU 5391 水题。

    E - 5 Time Limit:1500MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Statu ...

  8. 2014 ACM/ICPC Asia Regional Xi'an Online(HDU 5007 ~ HDU 5017)

    题目链接 A题:(字符串查找,水题) 题意 :输入字符串,如果字符串中包含“ Apple”, “iPhone”, “iPod”, “iPad” 就输出 “MAI MAI MAI!”,如果出现 “Son ...

  9. hdu 1544 水题

    水题 /* * Author : ben */ #include <cstdio> #include <cstdlib> #include <cstring> #i ...

随机推荐

  1. leetcode Roman to Integer python

    class Solution(object): def romanToInt(self, s): """ :type s: str :rtype: int "& ...

  2. 查看SQLServer数据库信息的SQL语句

    --查看数据库中的表信息, --包括(表名,记录数,保留空间,使用空间,索引使用空间,未用空间) exec sp_MSForEachTable @precommand=N'create table # ...

  3. java使用验证码进行登录验证

    随机生成4位验证码,将生成的4位数字字母数字放入session private static void outputVerifyCode(HttpServletRequest request, Htt ...

  4. 一个简单的web框架实现

    一个简单的web框架实现 #!/usr/bin/env python # -- coding: utf-8 -- __author__ = 'EchoRep' from wsgiref.simple_ ...

  5. 有关extern的用法

    1.引言 C++语言的创建初衷是“a better C”,但是这并不意味着C++中类似C语言的全局变量和函数所采用的编译和连接方式与C语言完全相同.作为一种欲与C兼容的语言, C++保留了一部分过程式 ...

  6. 解决Flex4 发布后访问 初始化极其缓慢的问题

    原文http://blog.163.com/vituk93@126/blog/static/170958034201282222046364/ 昨天找了个免费.net空间,想测试一下做的一个简单Fle ...

  7. Duanxx的图像处理学习: 透视变换(一)

    当人用眼睛看事物的时候,会感觉到近处的东西是比远处的东西要大一些的,通俗的说,这就是透视. 总的来说.透视变换是将3D的世界转换到2D图像上的一种手段,人的视觉系统和摄像头视觉系统也是基于这一工作原理 ...

  8. android项目 之 记事本(12) ----- 图片的等比例缩放及给图片加入边框

    本文是自己学习所做笔记.欢迎转载,但请注明出处:http://blog.csdn.net/jesson20121020 在Android的UI开发中常常会遇到图片的缩放,就比方记事本,如今的图片都比較 ...

  9. [Ext JS 4] 布局之实战一 - 中间区块不会自动伸展 (tab)

    前言 [Ext JS 4] 布局之实战一 - 中间区块不会自动伸展 (tab) 在上一篇中,中间的tab 区块无法自动伸展的原因一句话说就是: 使用contentEL的方式,相关HTML元素不会参与组 ...

  10. c/c++处理参数

    直接上代码:涉及函数getopt(),getopt_long() #include <unistd.h> #include <stdlib.h> #include <st ...