Cod sursa(job #1234278)
| Utilizator | Data | 26 septembrie 2014 23:28:39 | |
|---|---|---|---|
| Problema | Text | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.57 kb |
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
bool is_letter(char c) { return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'); }
int main()
{
char c;
bool k = false;
int words = 0, letters = 0;
FILE* in = fopen("text.in", "r");
FILE* out = fopen("text.out", "w");
while (c = fgetc(in))
{
if (feof(in))
{
break;
}
if (is_letter(c))
{
letters++;
if (k == false){
words++;
k = true;
}
}
else k = false;
}
fprintf(out,"%d", letters / words);
fclose(out);
return 0;
}
