Advertisement
Dragonkoko

سعيد

Dec 1st, 2013
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.19 KB | None | 0 0
  1.  
  2.  
  3.     #include <stdio.h>
  4.     #include <math.h>
  5.     #include <stdlib.h>
  6.     int main()
  7.     {
  8.         int i,j,c=0;
  9.         int g,t=1,n=0;
  10.         char a[10];
  11.         char l[200];
  12.         printf("enter your line \n");
  13.         gets(l);
  14.         printf("enter your word \n");
  15.         scanf("%s",a);
  16.         for(i=0;i<10;i++)
  17.         {
  18.             if(a[i]==0)
  19.             {
  20.                 break;
  21.             }
  22.             else
  23.             {
  24.                 c++;
  25.             }
  26.         }
  27.         for(i=0;i<200;i++)
  28.         {
  29.             t=1;
  30.             if(a[0]==l[i])
  31.             {
  32.                 for(j=1;j<c;j++)
  33.                 {
  34.                     if(a[j]==l[i+j])
  35.                     {
  36.                         t=0;
  37.                     }
  38.                     else
  39.                     {
  40.                         t=1;
  41.                         break;
  42.                     }
  43.  
  44.                 }
  45.             }
  46.             if(t==0)
  47.                 {
  48.                     n++;
  49.                     printf("%d",n);
  50.                     printf("occurrence at index %d \n",i);
  51.                 }
  52.         }
  53.         printf("total occurrence %d \n",n);
  54.         return 0;
  55.  
  56.  
  57.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement