Cod sursa(job #2194527)

Utilizator DooMeDCristian Alexutan DooMeD Data 13 aprilie 2018 17:54:02
Problema Text Scor 40
Compilator cpp Status done
Runda Arhiva de probleme Marime 1 kb
#include <iostream>
#include <fstream>
using namespace std;
ifstream f ("text.in");
ofstream g ("text.out");
string t;
long long i,nrc,ss,k,nrlc;
int main()
{
    while(f >> t) {
            cout << t << " ";
        if(t.size()==1) {
            if((t[0]>='a' and t[0]<='z')or (t[0]>='A' and t[0]<='Z')) {
                nrc++;
                ss+=t.size();
            }
        }
        else {
            k=1;
            if(t[t.size()-1]>'z' or(t[t.size()-1]<'a' and (t[t.size()-1]>'Z' or t[t.size()-1]<'A'))) k=2;
            nrc++;
            i=t.size()-k;
            nrlc=0;
            while((t[i]>='a' and t[i]<='z') or (t[i]>='A' and t[i]<='Z')) {
                nrlc++;
                i--;
            }
            if((t[i]>'z' or (t[i]<'a' and(t[i]>'Z' or t[i]<'A'))) and i>0) {
                nrc++;
                ss+=t.size()-k-nrlc-1;
            }
            else {
                ss+=nrlc;
            }
        }
    }
    g << ss/nrc;
    return 0;
}