Cod sursa(job #1221827)

Utilizator theCountRadulescu Vlad theCount Data 21 august 2014 16:03:53
Problema Text Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.75 kb
#define _CRT_SECURE_NO_WARNINGS
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <string.h>

using namespace std;

FILE *text = fopen("in.txt", "r");
FILE *textin = fopen("in.txt", "w");
FILE *textout = fopen("out.txt", "w");
int c = 0, n = 0, g = 1;
char ch;

int main()
{
	fprintf(textin, "%s", "- Lasa-ma in pace, ca am invatat azi noapte toata ziua!");
	fclose(textin);
	while (!feof(text))
	{
		ch = fgetc(text);
		if (isalpha(ch))
		{
			while (isalpha(ch))
			{
				ch = fgetc(text);
				c++;
			}
			n++;
		}

	}
	fclose(text);

	printf("n= %d", n);
	printf("c= %d", c);
	
	g = (int)c / n;

	printf("\n%d\n", g);

	fprintf(textout, "%d", g);
	fclose(textout);

	system("pause");
	return 0;
}