Cod sursa(job #497201)

Utilizator newbieFMI - Cristina Andrei newbie Data 1 noiembrie 2010 20:39:33
Problema Text Scor 40
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.71 kb
#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;
}