Pagini recente » Cod sursa (job #2703011) | Cod sursa (job #2119443) | Cod sursa (job #2534600) | Cod sursa (job #645507) | Cod sursa (job #497192)
Cod sursa(job #497192)
#include <fstream>
#include <string>
using namespace std;
int main() {
ifstream f("text.in");
ofstream g("text.out");
char t[10000];
int len, i, nrWord = 0, nrLetter = 0;
f.get(t,10000);
len = strlen(t);
i = 0;
while ( i < len )
if ( (((t[i] >= 'a') && (t[i] <= 'z')) || ((t[i] >= 'A') && (t[i] <='Z'))) && (i < len) ) {
while ( ( (t[i] >= 'a') && (t[i] <= 'z') ) || ( (t[i] >= 'A') && (t[i] <='Z') ) ) {
i++;
nrLetter++;
}
nrWord++;
}
else
while ( (!(((t[i] >= 'a') && (t[i] <= 'z')) || ((t[i] >= 'A') && (t[i] <='Z')))) && (i < len) ) {
i++;
}
g << nrLetter / nrWord;
return 0;
}