Pagini recente » Cod sursa (job #1909391) | Cod sursa (job #1757533) | Cod sursa (job #2857245) | Cod sursa (job #1561599) | Cod sursa (job #1501478)
#include <iostream>
#include <fstream>
using namespace std;
bool isLetter(char character)
{
int code=(int)character;
if((code>=65&&code<=90)||(code>=97&&code<=122))
return true;
return false;
}
int main()
{
ifstream fin("text.in");
ofstream fout("text.out");
char currentChar, lastChar='*';
int charCount=0, wordCount=0;
fin>>noskipws;
while(fin>>currentChar)
{
if(isLetter(currentChar))
charCount++;
else if(isLetter(lastChar))
wordCount++;
lastChar=currentChar;
}
fout<<charCount/wordCount;
return 0;
}