为什么会全部RE啊?
查看原帖
为什么会全部RE啊?
638110
nick360楼主2024/8/26 22:18
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>

int main(void){
	char ch,s[1000001],word[10];
	int ls=0,lw=0,find=0,cnt=0,loc=0;
	scanf("%s",word);
	lw=strlen(word);
	for(int jiji=0;jiji<lw;jiji++) word[jiji]=toupper(word[jiji]);
	ch=getchar();
	while((ch=getchar())!='\n'){
		if(ch>='a'&&ch<='z') ch=toupper(ch);
		s[ls++]=ch;
	}
	for(int i=0;i<ls;i++){
		if(s[i]==word[0]){
			if(s[i-1]==' '&&(s[i+lw]==' '||s[i+lw]=='\0')){
				int b=1;
				for(int fifi=1;fifi<lw;fifi++){
					if(s[i+fifi]!=word[fifi]){
						b=0;
						break;
					}
				}
				if(b==1){
					cnt++;
					if(find==0){
						find=1;
						loc=i;
					}
				}
			}
		}
	}
	if(find!=0) printf("%d %d\n",cnt,loc);
	else printf("-1\n");
	return 0;
}
2024/8/26 22:18
加载中...