Cod sursa(job #288169)

Utilizator yotherockerPuia Tudor yotherocker Data 25 martie 2009 16:48:56
Problema Text Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.55 kb
#include<fstream.h>   
#include<string.h>   
#include<ctype.h>


unsigned int aux,c,litere,cuvinte,medie;

main()
{
    ifstream In("text.in");
    ofstream Out("text.out");


    In>>c;
    if(isalpha(c)) cuvinte++;
    aux=c;

    while(!In.eof())
    {
	In>>c;
	if(isalpha(c)) litere++;
	if(isalpha(c) && !isalpha(aux)) cuvinte++;
	aux=c;
    }

    In.close();

    if(!litere || !cuvinte) Out<<medie<<'\n';
    else
    {
    medie=litere/cuvinte;
    Out<<medie<<'\n';
    }

    Out.close();
    return 0;   
  
}