Pagini recente » Cod sursa (job #2674459) | Cod sursa (job #1592861) | Cod sursa (job #1247189) | Cod sursa (job #1592881) | Cod sursa (job #1303329)
#include <fstream>
using namespace std;
int main()
{
char c;
int totalLength = 0, words = 0, length = 0;
ifstream f("text.in");
while (f >> noskipws >> c)
{
if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
length++;
else if (length)
{
totalLength += length;
words++;
length = 0;
}
}
f.close();
ofstream g("text.out");
g << totalLength / words;
g.close();
return 0;
}