Cod sursa(job #791891)

Utilizator idainetJohn Doe idainet Data 25 septembrie 2012 18:12:55
Problema Text Scor 40
Compilator cpp Status done
Runda asem-etapa1 Marime 0.92 kb
//
//  main.cpp
//  a1
//
//  Created by abc on 9/20/12.
//  Copyright (c) 2012 abc. All rights reserved.
//

# include <iostream>
# include <cstdio>
# include <cstdlib>
# include <iomanip>
# include <cmath>
# include <map>
# include <vector>
# include <set>

using namespace std;

# define ISALPHA(Q) (('a' <= Q && Q <= 'z') || ('A' <= Q && Q <= 'Z')) 
# define ISDIGIT(a) ('0' <= a  && a <= '9')
# define TODIGIT(a) (a - '0')

typedef unsigned char U8;
typedef long long LONG;

void init()
{
    freopen("text.in", "r", stdin);
    freopen("text.out", "w", stdout);
}

int main(int argc, const char * argv[])
{
    init();
    
    string text; getline(cin, text);
    text += '!';
    
    int len = 0, num = 0;
    for(int i=0; i<text.size(); ++i)
    {
        if (ISALPHA(text[i]))
        {
            while(ISALPHA(text[i])) ++len, ++i;
            ++num;
        }
    }
    
    cout << (num ? len/num:0);
    
    return 0;
}