Cod sursa(job #488009)

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

	}
	
	while (!isalpha(text[0])) strcpy(text,text+1);
	
	/*p=strchr(text,'.,!?:;()[]@#$%^&_+=/\|1234567890');
	while (p)
	{
		strcpy(p,p+1);
		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])) 
			{
				cout<<text[i]<<" ";
				contc++;
		}
	
	}
	//contc++;
	g<<contl/contc;
	
	return 0;
}