Cod sursa(job #93478)

Utilizator alexch16Chelariu Alexandru alexch16 Data 18 octombrie 2007 21:02:03
Problema Text Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.71 kb
#include <fstream.h>
#include <string.h>
#include <iomanip.h>

ifstream fin("text.in");
ofstream fout("text.out");

int str_len(char text[])
{
	int c=0, i;
	int s;

	s = strlen(text);

	for (i=0; i < s; i++)
		if (text[i]>='a' && text[i]<='z' || text[i]>='A' && text[i]<='Z') c++;
		
	return c;
}

int cuvinte (char text[])
{
	int cuv = 0;
	int s;
	 
	s = strlen(text);

	for (int i=0; i < s; i++)
		if (text[i] == ' ') cuv++;

	return cuv;
}

int main()
{
	char text[200];
	int l, cuv, t;

	int i=0;

	while (!fin.eof())
	{
		fin>>resetiosflags(ios::skipws)>>text[i];
		i++;
	}

	l = str_len(text);
	cuv = cuvinte(text)+1;

	t = l/cuv;

	fout<<t<<'\n';
	
	return 0;
}