Cod sursa(job #759106)
| Utilizator | Data | 16 iunie 2012 18:29:36 | |
|---|---|---|---|
| Problema | Text | Scor | 20 |
| Compilator | c | Status | done |
| Runda | Arhiva de probleme | Marime | 0.5 kb |
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define max 50
int main(){
FILE *in, *out;
char *number, *p;
int c = 0, lung = 0;
number = ( char *) malloc(max * sizeof(char));
in = fopen("text.in","r");
out = fopen("text.out","w");
if ( fgets(number,max, in ) != NULL ){
p = strtok( number, " ,.!-;:?" );
while ( p != NULL ){
c++;
lung += strlen(p);
p = strtok(NULL, " ,.!-;:?");
}
}
fprintf(out,"%d",lung/c);
free(number);
fclose(in);
fclose(out);
return 0;
}
