Pagini recente » Cod sursa (job #1639736) | Cod sursa (job #1710296) | Cod sursa (job #2344640) | Cod sursa (job #2127482) | 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;
}