Pagini recente » Cod sursa (job #482508) | Cod sursa (job #2967363) | Cod sursa (job #981215) | Cod sursa (job #2652890) | Cod sursa (job #497201)
Cod sursa(job #497201)
#include <fstream>
#include <string>
#define MAX 1000000
using namespace std;
char t[MAX];
int main() {
ifstream f("text.in");
ofstream g("text.out");
int len, i, nrWord = 0, nrLetter = 0;
f.get(t,MAX);
//g << t << endl;
len = strlen(t);
i = 0;
while ( i < len ) {
while ( ( (t[i] >= 'a') && (t[i] <= 'z') ) || ( (t[i] >= 'A') && (t[i] <='Z') ) ) {
i++;
nrLetter++;
}
nrWord++;
while ( (!(((t[i] >= 'a') && (t[i] <= 'z')) || ((t[i] >= 'A') && (t[i] <='Z')))) && (i < len) ) {
i++;
}
}
g << nrLetter / nrWord;
return 0;
}