Pagini recente » Cod sursa (job #2359047) | Cod sursa (job #690016) | Cod sursa (job #2671786) | Cod sursa (job #1634364) | Cod sursa (job #1349156)
//============================================================================
// 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;
}