Pagini recente » Cod sursa (job #1259036) | Cod sursa (job #977836) | Cod sursa (job #1301847) | Cod sursa (job #2848803) | Cod sursa (job #2672752)
#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;
}