codeforces水题100道 第二十三题 Codeforces Beta Round #77 (Div. 2 Only) A. Football (strings)

题目链接:http://www.codeforces.com/problemset/problem/96/A
题意:判断一个0-1字符串中出现的最长的0字串或者1字串的长度是否大于等于7。
C++代码:

#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
string s;
int tmp = 1;
bool chk()
{
    int len = s.length();
    for (int i = 1; i < len; i ++)
        if (s[i] == s[i-1])
        {
            tmp ++;
            if (tmp >= 7)
                return true;
        }
        else
            tmp = 1;
    return false;
}
int main()
{
    cin >> s;
    puts(chk() ? "YES" : "NO");
    return 0;
}
C++

 

posted @ 2016-07-20 21:07  月光诗人  阅读(180)  评论(0编辑  收藏  举报