Pagini recente » Cod sursa (job #2735346) | Cod sursa (job #1524855)
#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;
}