Cod sursa(job #1701260)

Utilizator borscalinCalin-Stefan Georgescu borscalin Data 12 mai 2016 16:36:50
Problema Text Scor 40
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.63 kb
#include <cstdio>
#include <cstring>

using namespace std;

char s[1048576];

inline bool my_isalpha(char x){
    if ((x >= 'A' && x <= 'Z') || (x >= 'a' && x <= 'z'))
        return 1;
    return 0;
}

int main(){
    FILE *fin, *fout;
    int n,i,cuv = 1,litere;
    fin = fopen("text.in","r");
    fgets(s,1048576,fin);
    fclose(fin);
    n = strlen(s);
    litere = my_isalpha(s[0]) + my_isalpha(s[n - 2]);
    for (i=1;i<n-2;i++){
        litere += my_isalpha(s[i]);
        cuv += (my_isalpha(s[i - 1]) && !my_isalpha(s[i]));
    }
    fout = fopen("text.out","w");
    fprintf(fout,"%d",litere / cuv);
    fclose(fout);
    return 0;
}