Pagini recente » Cod sursa (job #741297) | Cod sursa (job #3272988) | Cod sursa (job #1317266) | Cod sursa (job #3249176) | Cod sursa (job #3301458)
#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);
}