求助,在本地提交可以,但是上传全是re,为什么
查看原帖
求助,在本地提交可以,但是上传全是re,为什么
1252709
young020202楼主2024/3/19 21:34
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string.h>
#include<string>
#include<stdio.h>
#include<queue>
#include<ctype.h>
using namespace std;
char w[50],s[1000100];
int lw=0,ls=0;
int k=-1;
int sum=0;
bool f=0;
int main()
{
	while(1)
	{
		char a=getchar();
		if(a=='\n')
			break;
		else
			w[lw++]=a;
	}
	while(1)
	{
		char a=getchar();
		if(a=='\n')
			break;
		else
			s[ls++]=a;
	}
	for(int i=0;i<ls;i++)
		s[i]=tolower(s[i]);
	for(int i=0;i<lw;i++)
		w[i]=tolower(w[i]);
	for(int i=0;i<ls;i++)
	{
		int pre;
		if(s[i]==w[0])
		{
			if(f==0)	
				pre=i;
			int num=1;
			i++;
			for(int j=1;j<lw&&i<ls;j++,i++)
			{
				if(s[i]==w[j])
					num++;
				else
					break;
			}
			if(num==lw&&s[i]==' ')
			{
				sum++;f=1;k=pre;
			}
		}
	}
	if(k!=-1)
		cout<<sum<<" ";
	cout<<k;
}

2024/3/19 21:34
加载中...