| 记录编号 | 466996 | 评测结果 | AAAAAAAAAA | 
    
        | 题目名称 | 624.[NOIP 2011]统计单词数 | 最终得分 | 100 | 
    
        | 用户昵称 |  爆零自动机 | 是否通过 | 通过 | 
    
        | 代码语言 | C++ | 运行时间 | 0.219 s | 
    
        | 提交时间 | 2017-10-29 21:36:59 | 内存使用 | 0.31 MiB | 
    
    
    
    		显示代码纯文本
		
		#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
string word,say;
int pos=-1,ans;
bool first=true;
int main()
{
	freopen("stat.in","r",stdin);
	freopen("stat.out","w",stdout);
	 
	cin>>word;
	word=" "+word+' ';//string可以连接char和string 
	getline(cin,say);//处理换行符 
	getline(cin,say);//getline(cin,string)可以读入空格 
	say=" "+say+" ";
	
	for (int i=0; i<word.length(); i++)
		if (word[i]>='A' && word[i]<='Z')
			word[i]+=32;
	for (int i=0; i<say.length(); i++)
		if (say[i]>='A' && say[i]<='Z')
			say[i]+=32;
	
	unsigned int p=0;
	while ((p=say.find(word,p))!=string::npos)//string::npos 无符号整型1111 1111 1111 1111 1111 1111 1111 1111 
	{//string.find(string2,start,len) start:起始位置 len:查询长度 返回第一个位置下标
		if (first) pos=p,first=false;
		
		p++;//跳过查到的第一位 
		ans++;
	}
	if (first)
		cout<<-1<<endl;
	else
	{
		cout<<ans<<' '<<pos<<endl;
	}
	
	return 0;
}