Cod sursa(job #323081)
Utilizator | Data | 10 iunie 2009 17:36:13 | |
---|---|---|---|
Problema | Text | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.97 kb |
#include<cstdio>
#include<cstring>
#define maxn 2000007
using namespace std;
FILE *f=fopen("text.in","r");
FILE *g=fopen("text.out","w");
char x,y;
int i,n,p,k,ok;
int ch(char x)
{
if((x>='a'&&x<='z')||(x>='A'&&x<='Z'))
return 1;
return 0;
}
int main()
{
fscanf(f,"%c",&x);
if(x) ++k;
while(!feof(f))
if(x!=' '&&y)
{
if(ch(x))++k;
fscanf(f,"%c",&x);
}
else
{
n=0;
y=x;
fscanf(f,"%c",&x);
while(x!=' '&&!feof(f))
{
if(ch(x))
{
if(!ch(y))
++n;
if(!n) ++n;
++k;
}
y=x;
fscanf(f,"%c",&x);
}
if(n) p+=n;
}
fprintf(g,"%d\n",k/p);
fclose(f);
fclose(g);
return 0;
}