Cod sursa(job #1452007)

Utilizator bicycleghost808Dinu Taleanu bicycleghost808 Data 19 iunie 2015 14:53:37
Problema Text Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.47 kb
#include<iostream>
#include<fstream>
#include<string.h>
using namespace std;

int k, km, j;
char s[100];

int main()
{
	ifstream f("intrare.txt");
	f.get(s, 100);
	for (int i = 0; i < strlen(s); i++)
		if (((s[i] >= 'a') && (s[i] <= 'z')) || ((s[i] >= 'A') && (s[i] <= 'Z')))
			k++;
		else
			if (((s[i] == ' ') || (s[i] == '-')) && (k != 0))
			{
				j++;
				km += k;
				k = 0;
			}
	f.close();
	cout <<"Lungime medie este "<< km / j << "\n";
	return 0;
}