Cod sursa(job #880714)

Utilizator florin_hanganHangan Florin florin_hangan Data 17 februarie 2013 10:40:21
Problema Text Scor 80
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.78 kb
#include <fstream>
#include <string.h>
using namespace std;

ifstream is("text.in");
ofstream os("text.out");

int nr, nr_cuv, l;
bool Chr( char x );
char c[1000];

int main()
{
    for ( int i = 0; is >> c; i++ )
    {
        l = strlen( c );
        for ( int j = 0; j < l; ++j )
            if ( Chr ( c[j] ) )
                nr++;
        for ( int j = 1; j < l; ++j )
            if ( Chr(c[j]) && !Chr(c[j-1] ) )
                nr_cuv++;
        for ( int j = 0; j < l; ++j )
            if ( Chr ( c[j] ) )
            {
                nr_cuv++;
                break;
            }

    }
    os << nr / nr_cuv;
    return 0;
}
bool Chr(char x )
{
    if ( x <= 'z' && x >= 'a' || x <= 'Z' && x >= 'A' )
        return true;
    return false;
}