yhw999 edited 2 年,4 月前

#include<stdio.h>
#include<string.h>

#define W 1000
#define S 1000000

int main(){
	int T;
	scanf("%d",&T);
	for(int t=0;t<T;t++){
		char w[W];
		char w2[W];
		char s[S];
		char s2[S];
		scanf("%s",w);
		getchar();
		gets(s);
		
		for(int i=0;i<strlen(w);i++){
			if(w[i]>='A'&&w[i]<='Z'){
				w[i]=w[i]+32;
			}
		}
		w2[0]=' ';
		for(int i=0;i<strlen(w);i++){
			w2[i+1]=w[i];
		}
		w2[strlen(w)+2-1]=' ';
//		printf("w长度为:%d",strlen(w)); 
//		printf("w2长度为:%d",strlen(w2)); 
		
		for(int j=0;j<strlen(s);j++){
			if(s[j]>='A'&&s[j]<='Z'){
				s[j]=s[j]+32;
			}
		}
		
		s2[0]=' ';
		for(int i=0;i<strlen(s);i++){
			s2[i+1]=s[i];
		}
		s2[strlen(s)+2-1]=' ';
		
		int i=0,j=0;
		while(i<strlen(s2)&&j<strlen(w2)) {
			if(s2[i]==w2[j] ){
				i++;
				j++;
			}
			else{
				i=i-j+1;
				j=0;
			}
		}
		if(j==strlen(w2)){
			printf("case #%d:\n%d\n",t, i-strlen(w2)+1);
			continue;
		}
		printf("case #%d:\nNone\n",t);
	} 
	return 0;
}

Comments