Cod sursa(job #680277)

Utilizator nutipasa16Macovei Claudiu nutipasa16 Data 15 februarie 2012 11:26:32
Problema Text Scor 40
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.56 kb
#include<fstream>
#include<string.h>
#define dim 1000000
using namespace std;
ifstream f("text.in");
ofstream g("text.out");
char text[dim];
int n,l,nr,s;
int main()
    {f.get(text,dim);
	int i=0; n=strlen(text);
	while(i<n){if((text[i]<'A' || text[i]>'Z') && (text[i]<'a' || text[i]>'z'))text[i]=' ';
				i++;}
	i=0;
	while(i<n-1){if(text[i]==' ' && text[i+1]==' ')strcpy(text+i,text+i+1);
				i++;}
	if(text[0]==' ')strcpy(text,text+1);
	i=0;
	while(i<n)if(text[i]!=' '){l++;i++;}
			  else {nr++;s+=l; l=0; i++;}
	g<<s/nr<<" ";
    return 0;
    }