Difference between revisions of "Solução: Problema da competição alien (Daniel Rodrigues)"

From AdonaiMedrado.Pro.Br
Jump to: navigation, search
(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...)
 
 
Line 1: Line 1:
 +
<code lang="c">
 
#include <stdio.h>
 
#include <stdio.h>
 
#include <stdlib.h>
 
#include <stdlib.h>
Line 31: Line 32:
 
     printf("%d\n",resposta);
 
     printf("%d\n",resposta);
 
}
 
}
 +
</code>

Latest revision as of 14:08, 1 April 2009

#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++){
       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);
}