Pagini recente » Cod sursa (job #139719) | Cod sursa (job #693857) | Cod sursa (job #1826328) | Cod sursa (job #2190656) | Cod sursa (job #2810665)
#include <iostream>
#include <fstream>
#include <cstring>
using namespace std;
ifstream in("text.in");
ofstream out("text.out");
int lenght, wordsN;
int LenghtWord(char cuvant[])
{
int i = 0;
while (cuvant[i] != '\0')
{
i++;
}
return i;
}
int main()
{
char text[1000000];
in.get(text,999999);
char *cuvant;
cuvant = strtok(text," .,-!?");
lenght += LenghtWord(cuvant);
wordsN = 1;
while (cuvant != NULL)
{
cuvant = strtok(NULL," .,-!?");
lenght += LenghtWord(cuvant);
++wordsN;
}
out << lenght / wordsN;
return 0;
}