Cod sursa(job #1693770)
| Utilizator | Data | 23 aprilie 2016 20:42:48 | |
|---|---|---|---|
| Problema | Text | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.69 kb |
#include<iostream>
#include<fstream>
using namespace std;
int main()
{
ifstream f("text.in");
char c;
int countWords=0;
int countLocalLetters=0;
int countGlobalLetters=0;
f >> noskipws;
while(f>>c)
if(isalpha(c))
{
if(countLocalLetters!=0)
countLocalLetters++;
else
{
countWords++;
countLocalLetters=1;
}
countGlobalLetters++;
}
else
countLocalLetters=0;
f.close();
ofstream g("text.out");
g<<countGlobalLetters/countWords;
g.close();
return 0;
}
