Cod sursa(job #1064253)
Utilizator | Data | 21 decembrie 2013 18:04:47 | |
---|---|---|---|
Problema | Text | Scor | 40 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.99 kb |
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int main()
{
int len, i, l = 0, s = 0, n = 0;
string str;
ifstream infile;
infile.open("text.in");
ofstream outfile;
outfile.open("text.out");
getline(infile, str);
len = str.length() - 1;
for (i = 0; i <= len; i += 1) {
if (i == len) {
if (isalpha(str[i])) {
l += 1;
s += l;
n += 1;
}
else {
s += l;
n +=1;
}
}
if (isalpha(str[i])) {
l += 1;
}
if (!(isalpha(str[i]))) {
if (l != 0) {
s += l;
l = 0;
n += 1;
}
}
}
outfile << s / n;
infile.close();
outfile.close();
cout << s << endl;
cout << n;
return 0;
}