Pagini recente » Cod sursa (job #3352264) | Cod sursa (job #1849327) | Monitorul de evaluare | Cod sursa (job #2772201) | 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;
}