Cod sursa(job #1878659)
Utilizator | Data | 14 februarie 2017 12:46:37 | |
---|---|---|---|
Problema | Text | Scor | 70 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.54 kb |
#include <iostream>
#include <string.h>
#include <fstream>
using namespace std;
ifstream f("text.in");
ofstream g("text.out");
int nrlit,nrcuv;
char s[1000000000],sep[]=" ,.?-_!;:";
int main()
{
while(f.getline(s,1000000000))
{
for(int i=0;i<strlen(s);i++)
if( (s[i]>='a' && s[i]<='z') || (s[i]>='A' && s[i]<='Z') )nrlit++;
char *p=strtok(s,sep);
while(p)
{
nrcuv++;
p=strtok(NULL,sep);
}
}
g<<nrlit/nrcuv;
f.close();
g.close();
return 0;
}