Pagini recente » Cod sursa (job #2060497) | Cod sursa (job #2787122) | Cod sursa (job #137657) | Cod sursa (job #253027) | Cod sursa (job #2911506)
#include <iostream>
#include<cstdio>
using namespace std;
const int Nmax=1000000;
int is_letter(char c) {
if (('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z')) {
return 1;
}
return 0;
}
int main()
{
FILE *fin;
fin=fopen("text.in", "r");
freopen("text.out", "w", stdout);
char ch;
int wordlength=0;
int nrletter=0;
int nrwords=0;
while(!feof(fin))
{
fscanf(fin, "%c", &ch);
if(feof(fin))break;
if(is_letter(ch)){wordlength++;
}
else {
if(wordlength!=0){
nrwords++;
nrletter+=wordlength;
wordlength=0;
}
}
}
cout<<nrletter/nrwords;
}