Cod sursa(job #2810670)
| Utilizator | Data | 29 noiembrie 2021 22:36:40 | |
|---|---|---|---|
| Problema | Text | Scor | 40 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.62 kb |
#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[1000001];
in.get(text,1000000);
char *cuvant;
cuvant = strtok(text," .,-!/;'[]{}()*?");
while (cuvant != NULL)
{
lenght += LenghtWord(cuvant);
++wordsN;
cuvant = strtok(NULL," .,-!/;'[]{}()*?");
}
out << lenght / wordsN;
return 0;
}