分析:常规题,一次扫描即可,但要注意大小写和没出先要输出-1.判断是否是某个单词的一部分可以通过判断后一个词是不是空格或\0来解决。上题。
 1 #include <stdio.h>
 2 #include<string.h>
 3 #define MAX 1000
 4 int main()
 5 {
 6     char str[MAX];
 7     char word[MAX];
 8     int i,lenth,j=0;    
 9     int t,L;
10     int num=0,pos;
11      gets(word);
12      gets(str);
13     lenth=strlen(str);        
14     L=strlen(word);
15      for(i=0;i<lenth;i++)
16      {
17          if(str[i]==word[j]||(str[i]+32)==word[j]||(str[i]-32)==word[j])        //大小写一样也可以 
18          {
19              j++;
20              if(j==1) t=i;    //标记第一次的位置 
21          }
22          else
23          {
24              j=0;        //不是该单词清零 
25          }
26          if(j==L&&(str[i+1]==' '||str[i+1]=='\0'))    //判断是不是某词的一部分 
27          {
28              if(num==0) pos=t;
29              num++;
30          }
31      }
32      if(num==0) printf("-1");
33      else printf("%d\n%d",num,pos);
34     return 0;
35 }