Pagini recente » Cod sursa (job #629065) | Cod sursa (job #764042) | Cod sursa (job #2807494) | Cod sursa (job #2807495) | Cod sursa (job #793357)
Cod sursa(job #793357)
#include <fstream>
#include <ctype.h>
using namespace std;
int main()
{
ifstream f("text.in");
ofstream g("text.out");
char c,c2;
unsigned int wordNr=0, textLength=0;
short int k=0;
while(!f.eof())
{
f.get(c);
if(isalpha(c))
{
textLength++;
if(k==0)
wordNr++;
k=1;
}
else
k=0;
}
//caz wordNr = 0
if(wordNr==0)
{
g<<0;
return 0;
}
g<<(int)textLength/wordNr;
}