40分代码求助大佬
查看原帖
40分代码求助大佬
255791
衛宮士郎楼主2023/11/1 10:18

下载次数用完了,一道样例都看不了 /(ㄒoㄒ)/~~

#include<stdio.h>
#include<iostream>
#include<string.h>
using namespace std;
const int N=10e6+1;
char w[11], a[N];
int main()
{
char t='0';
int total=0,i=0,j=0,pos=0;
gets(w);
gets(a);
int len1=strlen(a),len2=strlen(w);
while(i<len1)
{
	if(j>=len2)
	{
		total++;
		if(total==1)
		pos=i-j;
		j=0;
	}
	if(a[i]>'A'&&a[i]<'Z')
		a[i]=a[i]+32;
	if(w[j]>'A'&&w[j]<'Z')
		w[j]=w[j]+32;		
	if(a[i]==w[j])
	{
	i++,j++;
	}else{
		j=0;
		i=i-j+1;
	}
}
	if(total)
	cout<<total<<" "<<pos;
	else cout<<-1;
} 
2023/11/1 10:18
加载中...