GatoBooster

CadenaPoderosa

Sep 6th, 2017
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.82 KB | None | 0 0
  1. #include  <stdio.h>
  2. #include  <string.h>
  3. #define MAX 10001
  4.  
  5. int main(void)
  6. {
  7.     int n;
  8.     scanf("%d",&n);
  9.     getchar();
  10.    
  11.     char cadena[MAX];
  12.    
  13.     int i;
  14.    
  15.     for (i = 0 ; i < n ; i++) {
  16.         scanf("%10001[^\n]s",cadena);
  17.         getchar();
  18.         int contador = 0;
  19.         char *puntero;
  20.         puntero = cadena;
  21.        
  22.         while ( (puntero = strstr(puntero,"heavy")) != NULL ) {
  23.             char *puntero2;
  24.             puntero2 = puntero + 5;
  25.             while ( (puntero2 = strstr(puntero2,"metal") ) != NULL ) {
  26.                  contador++;
  27.                  puntero2= puntero2 + 5;
  28.             }
  29.             puntero = puntero + 5;
  30.         }    
  31.                
  32.         printf("cadenas poderosas = %d\n",contador);    
  33.            
  34.            
  35.     }
  36.    
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment