SHARE
TWEET

Untitled

a guest May 26th, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2.  
  3. void main()
  4. {
  5.     char mot[100];
  6.     char phrase[49] = "this is the l phrase that  arisse going to useis";
  7.     phrase[48] = '\0';
  8.    
  9.  
  10.     scanf("%s", mot);
  11.  
  12.     int compteur = 0;
  13.     int sizeword = 0;
  14.     int sizephrase = 0;
  15.     while(phrase [sizephrase] != '\0'){
  16.         sizephrase++;
  17.     }
  18.     sizephrase++;
  19.     while(mot [sizeword] != '\0'){
  20.         sizeword++;
  21.     }
  22.     sizeword++;
  23.     int j = 0;
  24.     for(int i = 0; i < sizephrase - sizeword; i++){
  25.         if(phrase[i] == mot[j]){
  26.             j++;       
  27.         }
  28.         if(j == sizeword - 1){
  29.             compteur++;
  30.             j = 0;
  31.         }
  32.     }
  33.  
  34.     printf("The number of appearances is %d\n", compteur);
  35.  
  36.  
  37.     return;
  38. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top