Cod sursa(job #1524855)
| Utilizator | Data | 14 noiembrie 2015 15:01:20 | |
|---|---|---|---|
| Problema | Text | Scor | 40 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.55 kb |
#include <fstream>
using namespace std;
#define LUNG_MAX 1030
ifstream fin("text.in");
ofstream fout("text.out"); // fisierele
char text[LUNG_MAX + 1];
int i, cuvinte, lungime, eCuvant;
int main()
{
fin.getline(text + 1, LUNG_MAX); // citeste din fisier
for (i = 1; text[i] != '\0'; i++)
if (('a' <= text[i] && text[i] <= 'z') || ('A' <= text[i] && text[i] <= 'Z')) // daca e litera
{
lungime++;
eCuvant = 1;
}
else if (eCuvant == 1)
{
cuvinte++;
eCuvant = 0;
}
fout << lungime / cuvinte;
return 0;
}