为何下载数据本地测试输出和洛谷输出不一样呢?

P1308 [NOIP2011 普及组] 统计单词数

```c #include <stdio.h> #include <string.h> //统一字符串小写 void toLow(char *s){ for(int i=0; i<strlen(s); i++){ if (s[i]>='A' && s[i]<='Z') s[i]+=32; } } //检测两个字符串 void checkWord(char *word, char *leg){ int wordLength = strlen(word); int startIndex = -1,count=0; for(int i = 0; i <strlen(leg);i++){ if (leg[i] == word[0]){//找到第一个相同的字母开始检测是否为单词 //先判断单词前后为空格或者\0然后再检测区间内容 if (i + wordLength <=strlen(leg) && (i == 0 || (leg[i-1] == ' ' || leg[i-1] == '\0')) && (leg[i+wordLength] == ' ' || leg[i+wordLength] == '\0')){ int match = 1; for(int j = 0; j<wordLength; j++){ if (word[j] != leg[i+j]){ match = 0; break; } } if (match){ //如果没记录起始点记录 if (startIndex == -1) startIndex = i; count++; i+=wordLength; } } } } if (count != 0){ printf("%d %d",count,startIndex); }else{ printf("%d",startIndex); } } int main() { char a[12] = "td",b[1000002] = " Td tLWCsrmt"; scanf("%s",a); scanf("%s",b); toLow(a); toLow(b); checkWord(a,b);; return 0; } //第一次发帖 sorry ```
by vvalker @ 2019-04-11 17:41:43


下载的数据有问题
by Indekkusu @ 2019-04-14 23:15:39


td Td tLWCsrmt 输出是2 1 ???
by SunnCloud @ 2019-04-23 22:03:53


@[zxd_503290145](/space/show?uid=153072) 我也很奇怪这个
by 烈火金涛 @ 2019-04-26 23:58:01


@[zxd_503290145](/space/show?uid=153072) 是1 2
by ガイ @ 2019-06-14 16:09:16


|