首页 > 其他 > 详细

XidianOJ 1140 寻找万神

时间:2016-11-21 12:06:08      阅读:154      评论:0      收藏:0      [点我收藏+]

技术分享

--正文

直接用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 寻找万神

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!