Pagini recente » Monitorul de evaluare | Profil M@2Te4i | Cod sursa (job #181306) | Cod sursa (job #1344946) | Cod sursa (job #29943)
Cod sursa(job #29943)
#include <string.h>
#include <fstream.h>
using namespace std;
int main()
{
char text[1048576];
ifstream read("text.in");
ofstream write("text.out");
read.getline(text, 1048578);
unsigned int length = strlen(text);
unsigned int i, litere = 0, cuvinte = 2;
for(i = 0; i < length; ++i)
if (isalpha(text[i]))
litere++;
else if(i>=1 && text[i] == ' ' && isgraph(text[i-1]) && isgraph(text[i+1]))
cuvinte++;
else if(i>=1 && text[i] == '-' && isgraph(text[i-1]) && isgraph(text[i+1]))
cuvinte++;
else if(text[i] == '-' && isgraph(text[i+1]))
cuvinte++;
write << litere / cuvinte;
return 0;
}