码迷,mamicode.com
首页 > 其他好文 > 详细

XidianOJ 1140 寻找万神

时间:2016-11-21 12:09:18      阅读:194      评论:0      收藏:0      [点我收藏+]

标签:div   ges   code   class   print   scan   for   har   技术   

技术分享

--正文

直接用strstr就过了....

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;

char str[10000000];
char str2[10000000];
int main(){
    int n;
    while (scanf("%d",&n) != EOF){
        scanf("%d",&n);
        int i;
        str[0] = \0;
        for (i=1;i<=n;i++){
            scanf("%s",str2);
            strcat(str,str2);            
        }
        char* now = str;
        long ans = 0;
        long len = strlen(str);
        while (now != NULL){
            now = strstr(now,"wanshen");
            if (now != NULL) {
                now ++;
            }
            else break;
            ans ++;
            if (now == \0) break;
        }    
        printf("%ld\n",ans);
    }
    return 0;
}

 

XidianOJ 1140 寻找万神

标签:div   ges   code   class   print   scan   for   har   技术   

原文地址:http://www.cnblogs.com/ToTOrz/p/6084807.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!