Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <cs50.h>
- #include <string.h>
- #include <math.h>
- int main(void){
- string s = get_string("Text: ");
- int cletra = 0, cpalavra = 1, cfrase = 0;
- float L, S, x;
- //conta o total de letras
- for(int i=0, n=strlen(s); i<n; i++){
- if((s[i] >= 'a' && s[i] <= 'z') || (s[i] >= 'A' && s[i] <= 'Z')){
- cletra++;
- }
- }
- //conta o total de palavras
- for(int i=0, n=strlen(s); i<n; i++){
- if(s[i] == ' '){
- cpalavra++;
- }
- }
- //conta o total de frases
- for(int j=0, n=strlen(s); j<n; j++){
- if((s[j] == '.') || (s[j] == '!') || (s[j] == '?')){
- cfrase++;
- }
- }
- L = ((float) cletra/ (float) cpalavra)*100;
- S = ((float) cfrase/ (float) cpalavra)*100;
- x = 0.0588 * (100 * (float) cletra / (float) cpalavra) - 0.296 * (100 * (float) cfrase / (float) cpalavra) - 15.8;
- if(x>=16){
- printf("Grade 16+\n");
- }else{
- printf("Grade %i\n", (int) round(x));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement