Solução: Problema da competição alien (Daniel Rodrigues)

From AdonaiMedrado.Pro.Br
Revision as of 13:56, 1 April 2009 by 200.17.147.2 (Talk) (New page: #include <stdio.h> #include <stdlib.h> #include <string.h> void main() { char frase[250]; char palavra[10]; int i,N,j=0,k,resposta=0; for(k=0;k<10;k++){ palav...)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
  1. include <stdio.h>
  2. include <stdlib.h>
  3. include <string.h>


void main() {

   char frase[250];
   char palavra[10];
   int i,N,j=0,k,resposta=0;
   
   for(k=0;k<10;k++){
      palavra[k]='\0';
   }
   scanf("%d\n",&N);
   gets(frase);
   for(i=0;i<strlen(frase);i++){
       if((frase[i]>96) && (frase[i]<123)){
           palavra[j]=frase[i];
           j++;
       }
       else{
           if(strlen(palavra)==N)
               resposta++;
           j=0;                      
           for(k=0;k<10;k++)
             palavra[k]='\0';
       }
       if((i==strlen(frase)-1)&& (strlen(palavra)==N))
           resposta++;
   }
   printf("%d\n",resposta);

}