Pagini recente » Cod sursa (job #1640208) | Cod sursa (job #1986546) | Cod sursa (job #1247804) | Cod sursa (job #2013710) | Cod sursa (job #782340)
Cod sursa(job #782340)
#include<iostream>
#include<fstream>
#include <math.h>
using namespace std;
int main()
{
ifstream infile;
ofstream outfile;
infile.open ("text.in");
char c;
bool word = false;
long chars = 0;
long total = 0;
while(!infile.eof())
{
infile.read(&c, 1);
//infile >> c;
if((c >= 'a' && c <='z') || (c >= 'A' && c <= 'Z'))
{
chars++;
word = true;
}
else
{
if(word)
total ++;
word = false;
}
}
if(word) total ++;
//cout << chars;
//cout << total;
infile.close();
outfile.open ("text.out");
outfile << chars / total;
outfile.close();
return 0;
}