Cod sursa(job #488013)

Utilizator pmndanielDaniel Pomeanu pmndaniel Data 27 septembrie 2010 12:51:56
Problema Text Scor 40
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.68 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;
	f.get (text,256);
	
	p=strchr(text,'.,!?:;()[]@#$%^&_+=/\|1234567890-');
	while (p)
	{
		strcpy(aux,p+1);
		strcpy(p," ");
		strcat(p+1,aux);
		p=strchr(p,'.,!?:;()[]@#$%^&_+=/\|1234567890-');

	}
	
	p=strchr (text, ' ');
	while (p)
	{
		if (*(p+1)==' ') strcpy(p,p+1);
        p=strchr(p+1, ' ');
	}
	
	
	for (i=0;i<strlen(text);i++)
	{
		if (isalpha(text[i])) contl++;
		if (isalpha(text[i])&& isspace(text[i+1])) contc++;
	}
	contc++;
	
	g<<contl/contc;
	
	return 0;
}