Initiate Luogu
This commit is contained in:
38
Luogu/P1308 [NOIP 2011 普及组] 统计单词数.cpp
Normal file
38
Luogu/P1308 [NOIP 2011 普及组] 统计单词数.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
int main(){
|
||||
char a[100001];
|
||||
char test[11];
|
||||
scanf("%s",test);
|
||||
getchar();
|
||||
scanf("%[^\n]",a);
|
||||
int js=0;
|
||||
//printf("strlen's test:%d\n",strlen(a));
|
||||
for(int i=0;i<strlen(test);i++){
|
||||
test[i]=tolower(test[i]);
|
||||
}
|
||||
for(int i=0;i<strlen(a);i++){
|
||||
a[i]=tolower(a[i]);
|
||||
}
|
||||
int start=0;
|
||||
bool flag=false;
|
||||
for(int i=0;i<=strlen(a);i++){
|
||||
int j=i;
|
||||
//printf("before:%d ",j);
|
||||
while(a[j]==test[j-i]&&(j-i)<=strlen(test)){
|
||||
j++;
|
||||
}
|
||||
//printf(" after:%d\n",j);
|
||||
if((j-i)==strlen(test)||(j-i)==strlen(test)+1)
|
||||
js++;
|
||||
if(js==1&&flag==false){
|
||||
start=i;
|
||||
flag=true;
|
||||
}
|
||||
}
|
||||
if(js!=0) printf("%d %d",js,start);
|
||||
else printf("-1");
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user