Pagini recente » Cod sursa (job #307216) | Cod sursa (job #1726951) | Cod sursa (job #1307617) | Cod sursa (job #2138819) | Cod sursa (job #131570)
Cod sursa(job #131570)
#include <cstdio>
using namespace std;
int const MAX = 1024 * 1024;
char text[4+MAX];
int
main () {
FILE * io = fopen ("text.in", "r");
setvbuf(io, NULL, _IOFBF, MAX);
fgets(text, 1+MAX, io);
fclose(io);
int s=0, n=0, i=0, m = 0;
while('\0' != text[i]) {
while ( '\0' != text[i] &&
!('a' <= text[i] && 'z' >= text[i]) &&
!('A' <= text[i] && 'Z' >= text[i]) ) ++ i; // while
while ( ('a' <= text[i] && 'z' >= text [i]) ||
('A' <= text[i] && 'Z' >= text [i]) ) { ++i; ++ m; }
if (0 < m) {
++ n; s += m; m = 0;
}
}
if (0 < n) m = s / n; else m = 0;
io = fopen ("text.out", "w");
fprintf (io, "%d\n", m);
fclose (io);
return 0;
}