Cod sursa(job #3301458)
Utilizator | Data | 26 iunie 2025 16:53:01 | |
---|---|---|---|
Problema | Text | Scor | 20 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.46 kb |
#include <stdio.h>
#include <string.h>
using namespace std;
int main()
{
FILE *file_in = fopen("text.in", "r");
FILE *file_out = fopen("text.out", "w");
char text[1024];
int l = 0, nr = 0;
fgets(text, sizeof(text), file_in);
char *s = strtok(text, " ,.-:!?");
while (s) {
l += strlen(s);
nr++;
s = strtok(NULL, " ,.-:!?");
}
fprintf(file_out, "%d\n", l / nr);
fclose(file_in);
fclose(file_out);
}