Cod sursa(job #1349156)

Utilizator andy94Andrei Ursache andy94 Data 20 februarie 2015 00:06:53
Problema Text Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.8 kb
//============================================================================
// Name        : Text.cpp
// Author      : Andrei
// Version     :
// Copyright   : Your copyright notice
// Description : Text - InfoArena
//============================================================================

#include <iostream>
#include <stdlib.h>
#include <stdio.h>
using namespace std;

int main() {

	FILE *in = fopen("text.in", "r");
	FILE *out = fopen("text.out", "w");

	int w=0;
	int l=0;

	char data[512];
	char delim[] = " ,.?!-_}{[]\\|/:;\'\"";
	char *p;
	while (!feof(in)) {
		fread(data, 1, 512, in);
		p = strtok(data, delim);
		while(p!=NULL){
			w++;
			l+=strlen(p);
			p = strtok(NULL,delim);
		}

	}

	int r = l/w;
	char result[3];
	itoa(r,result,10);
	fputs(result,out);

	fclose(in);
	fclose(out);

	return 0;
}