Cod sursa(job #497187)

Utilizator newbieFMI - Cristina Andrei newbie Data 1 noiembrie 2010 20:12:26
Problema Text Scor 30
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.84 kb
#include <iostream>
#include <fstream>
#include <string>

using namespace std;

int main() {
    ifstream f("text.in");
    ofstream g("text.out");
    char t[100];
    int len, i, nrWord = 0, nrLetter = 0;
    f.get(t,100);
    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;
}