Cod sursa(job #2442308)

Utilizator AlexPatroiPatroi Alex AlexPatroi Data 23 iulie 2019 17:01:03
Problema Text Scor 100
Compilator c-64 Status done
Runda Arhiva de probleme Marime 0.48 kb
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void main() {
	FILE *fp = fopen("text.in", "a+t");

	int lungime = 0;
	int nr_cuv = 0;
	int ok = 0;
	char c;
	while ((c = fgetc(fp)) != EOF)
		if (c >= 'A' && c <= 'Z' || c >= 'a' && c <= 'z') {
			lungime++;
			if (!ok) {
				nr_cuv++;
				ok = 1;
			}
		}
		else
			ok = 0;

	fclose(fp);
	int res = lungime / nr_cuv;

	fp = fopen("text.out", "w+t");
	fprintf(fp, "%d", res);
	fclose(fp);
	return 0;
}