Advertisement
weldisalves

Lista 04 - exercício 36

Jun 22nd, 2013
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.68 KB | None | 0 0
  1.  
  2.  
  3.     #include <stdio.h>
  4.     #include <string.h>
  5.     #define MAX 10000
  6.  
  7.     /* 36. Dado um texto de entrada, verifique quantas vezes aparecem ocorrências da palavra ‘web’. */
  8.  
  9.     int main()
  10.     {
  11.         char texto[MAX];
  12.         int i,existe=0;
  13.  
  14.         printf("\n Digite o texto: \n");
  15.         fgets(texto,MAX,stdin);
  16.  
  17.         for(i=0;i<strlen(texto);i++)
  18.         {
  19.             if((texto[i]==87 || texto[i]==119)&&(texto[i+1]==69 || texto[i+1]==101)&&(texto[i+2]==66 || texto[i+2]==98))
  20.             {
  21.                 existe++;
  22.             }
  23.         }
  24.  
  25.         printf("\n A palavra 'web' existe %d vezes!!",existe);
  26.  
  27.         getchar();
  28.         return 0;
  29.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement