Pagini recente » Cod sursa (job #1319183) | Cod sursa (job #429736) | Cod sursa (job #1801251) | Cod sursa (job #833791) | Cod sursa (job #2672754)
#include <iostream>
#include <string.h>
#include <fstream>
using namespace std;
int main()
{
ifstream fin("text.in");
ofstream fout("text.out");
char text[1000], *p;
int nrChar = 0, nrWords = 0;
fin.get(text, 1000);
p = strtok(text, " -");
while (p) {
bool isWord = false;
for (int i = 0; i < strlen(p); ++i) {
if ((p[i] >= 'a' && p[i] <= 'z') || (p[i] >= 'A' && p[i] <= 'Z')) {
nrChar++;
isWord = true;
}
}
if (isWord) {
nrWords++;
}
p = strtok(NULL, " -");
}
fout << nrChar / nrWords;
return 0;
}