Advertisement
weldisalves

Lista 04 - exercício 34

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