Cod sursa(job #2383366)
Utilizator | Ioana Draganescu IoanaDraganescu | Data | 19 martie 2019 13:11:16 |
---|---|---|---|
Problema | Text | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.64 kb |
#include <iostream>
#include <fstream>
#include <cstring>
using namespace std;
ifstream fin("text.in");
ofstream fout("text.out");
int lit(char x)
{
if ((x <= 'Z' && x >= 'A') || (x <= 'z' && x >= 'a'))
return 1;
return 0;
}
int main()
{
int x = 0, y = 0, nr = 0;
char c;
while (fin.get(c))
{
if (lit(c))
{
nr++;
if (nr == 1)
y++;
}
else
{
x += nr;
nr = 0;
}
}
if (y == 0)
fout << 0 << '\n';
else
fout << x / y << '\n';
return 0;
}