Pagini recente » Cod sursa (job #179533) | Statistici Ablachim Mert-Kayhan (kayhy2323) | Cod sursa (job #2230234) | Cod sursa (job #2261293) | Cod sursa (job #1480494)
/* Author: Raul Vasile
* Mail: [email protected]
*/
#include <stdio.h>
#include <string.h>
int main(int argc, char* argv[]) {
// Declarare variable
int c;
int length = 0;
int words = 0;
int word = 0;
// Declarare fisiere
FILE *input, *output;
// Deschidere fisiere
input = fopen("text.in", "r");
output = fopen("text.out", "w");
// Verificare fisiere
if (input == NULL || output == NULL) {
printf("Error opening files");
return 0;
} else {
do {
c = fgetc(input);
if ((c < 91 && c > 64) || (c < 123 && c > 96)) {
length++;
word = 0;
} else {
if (word == 0) {
words++;
word = 1;
}
}
} while (c != EOF);
fprintf(output, "%d\n", length / words);
}
return 0;
}