Cod sursa(job #442567)

Utilizator bktzBogdan Chitu bktz Data 14 aprilie 2010 20:14:02
Problema Text Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.61 kb
#include <iostream>
#include <fstream>   
using namespace std;

bool isLetter(char a){
     return  (((a>='a')&&(a<='z'))||((a>='A')&&(a<='Z')));
     }

int main()
{
	char x;
	int nr_litere=0,cuvinte=0;
    FILE *fp;
    fp=fopen("text.in", "r");
	ofstream g;
    g.open("text.out");
	bool c=false;
    while (x != EOF)
    {
    x = fgetc (fp);
    if (isLetter(x)){
                     nr_litere++;                 
	                 if (!c){ cuvinte++; c=true;}
                     }
        else c=false;
        }
    
    g<<(int)(nr_litere/cuvinte);

	fclose(fp);
	g.close();
}