Pagini recente » Cod sursa (job #922659) | Cod sursa (job #2945277) | Cod sursa (job #2711721) | Cod sursa (job #2415228) | Cod sursa (job #1339648)
#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();
unsigned short letters = 0, words = 0, avg = 0;
for (unsigned 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;
}