Pagini recente » Cod sursa (job #1432450) | Cod sursa (job #632980) | Cod sursa (job #1589484) | Cod sursa (job #1686530) | Cod sursa (job #1303333)
#include <fstream>
using namespace std;
int main()
{
char c;
int totalLength = 0, words = 0, length = 0;
ifstream f("text.in");
while (f.get(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;
}