Cod sursa(job #942065)

Utilizator miu_mik93FMI - Paduraru Miruna miu_mik93 Data 20 aprilie 2013 17:05:28
Problema Text Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.83 kb
#include<iostream>
#include<stdlib.h> /* qsort */
#include <stdio.h> /* printf */
#include <math.h>
#include <queue>
#include <iomanip>
#include <string>
using namespace std;
int main()
{
	long long int n;
	char c;
	int nrCaractere = 0, nrCuvinte = 0;
	FILE *f = fopen("text.in", "r");
	FILE *g = fopen("text.out", "w");
	int i = 0;
	int gasit = 0;
	while (!feof(f))
	{
		fscanf(f, "%c", &c);
	//	text[i++] = c; 
		if(('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z'))
		{
			nrCaractere++;
			if(gasit != 1)
				nrCuvinte++;
			gasit = 1;
		}
		else
		{
			gasit = 0;
		}
	}
	/*text[i] = '\0';
	char v[5] = {'-' ,',', '!', '?' ,' '};
	char *p = strtok(text, v);
	while (p != NULL)
	{
		nrCuvinte++;
		p = strtok(NULL, v);
	}*/
	fprintf(g, "%d", nrCaractere/nrCuvinte);
	fclose(f);
	fclose(g);

	return 0;
}