Cod sursa(job #1524841)

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

using namespace std;

#define LUNG_MAX 1025

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

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

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

	fout << lungime / cuvinte;

	return 0;
}