Pagini recente » Cod sursa (job #59947) | Cod sursa (job #2199106) | Cod sursa (job #1894007) | Cod sursa (job #2292855) | Cod sursa (job #2194527)
#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;
}