Cod sursa(job #1873117)

Utilizator omnipedPopescu Octavian omniped Data 8 februarie 2017 19:57:14
Problema Text Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.62 kb




#include<iostream>
#include<string>
#include<fstream>
using namespace std;

int main()
{
	
	char p,c;
	int nr_cuvinte = 0, lungime = 0;
	ifstream fin("text.in");
	ofstream fout("text.out");
	fin >> p;
	if ((p >= 'A' && p <= 'Z') || (p >= 'a' && p <= 'z'))
	{
		lungime++;
		nr_cuvinte++;
	}
	while ( fin>>noskipws>>c)
	{
		if ((c < 'A' || c > 'Z') || (c < 'a' || c > 'z') && (p >= 'A' && p <= 'Z') || (p >= 'a' && p <= 'z'))
			nr_cuvinte++;
		if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'))
			lungime++;
		p = c;
		
		
	}
	fout << lungime / (nr_cuvinte + 1);
	fin.close();
	fout.close();
}