Advertisement
Guest User

Untitled

a guest
May 26th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement