Pagini recente » Cod sursa (job #2413840) | Cod sursa (job #1762480) | Cod sursa (job #1336656) | Cod sursa (job #1745972) | Cod sursa (job #154958)
Cod sursa(job #154958)
#include <iostream>
#include <fstream>
using namespace std;
char text[2000000];
int main(int argc, char *argv[]) {
FILE *fi = fopen("text.in", "rb");
fread(text, 1, sizeof(text), fi);
fclose(fi);
int len(0),
count(0);
bool inword(true);
for (char *c = text; *c; ++c) {
if (isalpha(*c)) {
++len;
if (!inword)
++count;
inword = true;
} else
inword = false;
}
++count;
if (!isalpha(*text))
--count;
cout << len << " " << count << " " << len/count << endl;
ofstream fout("text.out");
fout << len/count << endl;
fout.close();
return 0;
}