Pagini recente » Cod sursa (job #173305) | Cod sursa (job #154794) | Cod sursa (job #2407721) | Cod sursa (job #2401377) | Cod sursa (job #2020884)
#include <fstream>
#include <string.h>
using namespace std;
int main()
{
ifstream fin("text.in");
ofstream fout("text.out");
unsigned nrCuvinte = 0;
unsigned nrLitere = 0;
char bucata[1048576];
unsigned lungimeBucata;
bool hasLetter;
while(fin>>bucata){
lungimeBucata = strlen(bucata);
hasLetter = false;
for(int i = 0; i<lungimeBucata; i++){
if((bucata[i]<='z'&&bucata[i]>='a') || (bucata[i]<='Z'&&bucata[i]>='A')){
nrLitere++;
hasLetter = true;
}
else if(hasLetter){
nrCuvinte++;
hasLetter = false;
}
}
if(hasLetter) nrCuvinte++;
}
fout<<nrLitere/nrCuvinte;
fin.close();
fout.close();
return 0;
}