Cod sursa(job #487725)

Utilizator pmndanielDaniel Pomeanu pmndaniel Data 26 septembrie 2010 13:35:30
Problema Text Scor 40
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.65 kb
#include <fstream.h>
#include <string.h>
#include <iostream.h>
ifstream f ("text.in");
ofstream g ("text.out");

int main ()
{
	char text[100000],*p,aux[100000];
	int i,contc=0,contl=0,c=0;
	f.get (text,256);
	
	p=strchr(text,'-');
	while (p)
	{
		strcpy(aux,p+1);
		strcpy(p," ");
		strcat(p+1,aux);
		p=strchr(p,'-');

	}
	
	while (!isalpha(text[0])) strcpy(text,text+1);
	
	p=strchr(text,'.,!?:;');
	while (p)
	{
		strcpy(p,p+1);
		p=strchr(p,'.,!?:;');

	}
	
	
	for (i=0;i<strlen(text);i++)
	{
		if (isalpha(text[i])) contl++;
		if (isspace(text[i])) contc++;
	
	}
	contc++;
	g<<contl/contc;
	
	return 0;
}