Cod sursa(job #1524848)

Utilizator AndreiIstetulAndrei Andrei AndreiIstetul Data 14 noiembrie 2015 14:59:20
Problema Text Scor 40
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.57 kb
#include <fstream>

using namespace std;

#define LUNG_MAX 1025

ifstream fin("text.in");
ofstream fout("text.out"); // fisierele
char text[LUNG_MAX + 1];
int i, cuvinte, lungime, eCuvant;

int main(int argv, char **argc)
{
	fin.getline(text + 1, LUNG_MAX); // citeste din fisier

	for (i = 1; text[i] != NULL; i++)
		if (('a' <= text[i] && text[i] <= 'z') || ('A' <= text[i] && text[i] <= 'Z')) // daca e litera
		{
			lungime++;
			eCuvant = 1;
		}
		else if (eCuvant == 1)
		{
			cuvinte++;
			eCuvant = 0;
		}

	fout << lungime / cuvinte;

	return 0;
}