Cod sursa(job #915861)
| Utilizator | Data | 15 martie 2013 13:58:00 | |
|---|---|---|---|
| Problema | Text | Scor | 40 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.58 kb |
#include <iostream>
#include<fstream>
#include<string.h>
using namespace std;
int main()
{
ifstream f;
ofstream g;
f.open("text.in");
g.open("text.out");
char s[256], *p, e[]=" ,.!?;:(){}[]/\-""!\@#$%^&*_+<>|'`~";
int i,n=0,c=0;
float k;
f.get(s,256);
i=0;
while(isalpha(s[i])==0)
i++;
strcpy(s,s+i);
p=strtok(s,e);
while(p)
{
c++;
n+=strlen(p);
p=strtok(NULL, e);
}
k=(float)n/(float)c;
if(strlen(s)==0)
g<<"0";
else
g<<(int)k;
return 0;
}
