Advertisement
Dragonkoko

problem2

Dec 1st, 2013
320
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.58 KB | None | 0 0
  1. #include<stdio.h>
  2. main(){
  3.     char word[15],stat[256];
  4.     int flag = 0,i,j,cnt=0;
  5.     printf("statment pls.\n");
  6.     gets(stat);
  7.     printf("word pls.\n");
  8.     scanf("%s",word);
  9.     for (i=0;i<256;i++){
  10.             flag =0;
  11.         if (word[0]==stat[i]){
  12.             flag =1;
  13.             for(j=1;word[j]!=0;j++){
  14.                 if (word[j]!=stat[j+i]){flag=-1;break;}
  15.             }
  16.         }
  17.  
  18.         if (flag==1){
  19.             cnt++;
  20.             printf("occurence @ %d\n",i);
  21.         }
  22.     }
  23.     printf("Total number of occurrences = %d \n",cnt);
  24.     return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement