Cod sursa(job #953402)

Utilizator manutrutaEmanuel Truta manutruta Data 25 mai 2013 23:38:14
Problema Text Scor 30
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.86 kb
#include <iostream>
#include <fstream>
#include <string>
using namespace std;

#define endl '\n'

ifstream f("text.in");
ofstream g("text.out");

string letter = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM";

int isletter(char c)
{
    if((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
        return 1;
    return 0;
}

string s;
long long total, nrcuv;

int main()
{
    getline(f, s);

    for(int i = 0; i < s.size(); i++)
    {
        if(!isletter(s[i]) && !isletter(s[i-1]))
        {
            s.erase(i, 1);
            i--;
        }
        else if(!isletter(s[i]))
        {
            s[i] = ' ';
        }
    }
    cout << s << endl;

    while(s.find(' ') < s.size())
    {
        nrcuv++;
        total += s.find(' ');
        s = s.substr(s.find(' ') + 1);
    }


    g << total / nrcuv;
}