Pagini recente » Cod sursa (job #2181931) | Cod sursa (job #803387) | Cod sursa (job #281321) | Cod sursa (job #3041587) | Cod sursa (job #1210724)
/*******************************************************************************************
* .--. *
* ::\`--._,'.::.`._.--'/:: @author Ana M. Mihut @course InfoArena Tryout *
* ::::. ` __::__ ' .::::: @alias LT-Kerrigan @date 19.07.2014 *
* ::::::-:.`'..`'.:-:::::: @link http://infoarena.ro/problema/text *
* ::::::::\ `--' /:::::::: @detail "Use regex" they said "It'll be fun" they said *
* *
********************************************************************************************/
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <sstream>
#include <string>
#include <string.h>
using namespace std;
FILE *in = fopen("text.in", "r");
FILE *out = fopen("text.out", "w");
char c;
bool IsLetter(char c) { return (c >= 65 && c <= 90) || (c >= 97 && c <= 122); }
void AvgLen() {
int i = 0, countLetter = 0, countWords = 0;
while (fscanf(in, "%c", &c) != EOF){
if (IsLetter(c)){
countLetter++;
if (i == 0) countWords++;
i = 1;
}
else i = 0;
}
fprintf(out, "%d\n", countLetter / countWords);
}
int main(){
AvgLen();
return 0;
}