Cod sursa(job #1045285)

Utilizator DGVanceaDragos Gabriel Vancea DGVancea Data 1 decembrie 2013 12:07:49
Problema Text Scor 30
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.69 kb
#include <string.h>
#include <stdio.h>
using namespace std;
FILE *f=fopen("text.in","r");
FILE *g=fopen("text.out","w");

char s[15000] ;

int main()
{

    int i=0,lungt=0,nrcuv=0;
    char x;
    while(fscanf(f,"%c",&x)&& x!='\n')
    {
        s[i]=x;
        if((s[i]>='a'&& s[i]<='z' )||(s[i]>='A' && s[i]<='Z'))
            lungt++;
        else
        {
            if(i)
                if(strchr("qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM",s[i-1]))
                    nrcuv++;
        }
        i++;
    }
    if(strchr("qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM",s[i-1]))
       nrcuv++;
    fprintf(g,"%d",lungt/nrcuv);
    return 0;
}