Cod sursa(job #1428461)

Utilizator mihaistanusoiuStanusoiu Mihai mihaistanusoiu Data 4 mai 2015 16:38:50
Problema Text Scor 30
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.49 kb
#include<iostream>
#include<fstream>
#include<cstring>
using namespace std;
ifstream f("text.in");
ofstream g("text.out");
char alfabet[]="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",S[1200],*p;
int nr,x,Sum,k;

int main ()
{
	f.get(S,1200);
	do
	{
		nr++;
	}while(!strchr(alfabet,S[nr]));
	p=strtok(S+nr," ,:;.?!-1234567890");
	while(p)
	{
		x=strlen(p);
		Sum+=x;
		k++;
		p=strtok(NULL," ,:;.?!-1234567890");
	}
	if(k==0)
		g<<0;
	else
		g<<Sum/k;
	return 0;
}