Cod sursa(job #704793)

Utilizator seralex333Alexandru Serghie seralex333 Data 2 martie 2012 20:33:33
Problema Text Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.59 kb
#include<iostream>
#include<fstream>
#include<string>
using namespace std;
ifstream f ("text.in");
ofstream g ("text.out");

int i, nr_cuv, rez, lung;
char text[25000], aux[25000], *p;

void citire()
{
	f.get(text, 25000);
}

void rezolvare()
{
	strcpy(aux, text);
	
	p = strtok(text, " ,.!?-");
	while (p)
	{
		nr_cuv++;
		 p = strtok(NULL, " ,.!?-");
	}

	for (i = 0; i < strlen(aux); i++)
		if (strchr("- ,.?!", text[i]))
			lung++;
		
	rez = (strlen(aux) - lung) / nr_cuv;	
}

void afisare()
{
	g << rez;
}

int main()
{
	citire();
	rezolvare();
	afisare();
}