Pagini recente » Cod sursa (job #1801560) | Monitorul de evaluare | Cod sursa (job #2777174) | Cod sursa (job #2074304) | Cod sursa (job #680275)
Cod sursa(job #680275)
#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;
}