Pagini recente » Cod sursa (job #1428189) | Cod sursa (job #2817560) | Cod sursa (job #2883368) | Cod sursa (job #1269702) | Cod sursa (job #1339638)
#include <fstream>
#include <string>
using namespace std;
int main()
{
ifstream in_f("text.in");
ofstream out_f("text.out");
string text = "";
while (!in_f.eof())
{
getline(in_f, text);
}
int size = text.length(), letters = 0, words = 0, avg = 0;
for (int i = 0; i < size; i++)
{
if ((text[i] >= 'a' && text[i] <= 'z') || (text[i] >= 'A' && text[i] <= 'Z'))
{
if (text[i - 1] == ' ' || (text[i - 1] == '-'))
++words;
++letters;
}
}
avg = letters / words;
out_f << avg;
return 0;
}