Pagini recente » Rating Spaghetti Monster (spaghettimonster) | Cod sursa (job #2458183) | Cod sursa (job #923318) | Cod sursa (job #1022842) | Cod sursa (job #2523489)
#include <fstream>
#include <string>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#include <map>
#include <string.h>
#include <queue>
using namespace std;
#ifdef DEBUG
string name = "data";
#else
string name = "text";
#endif
ifstream fin(name + ".in");
ofstream fout(name + ".out");
int main() {
string s((istreambuf_iterator<char>(fin)), (istreambuf_iterator<char>()));
int l = 0;
int nw = 0;
bool didStartWord = false;
for (int i = 0; i < s.length(); ++i) {
char c = s[i];
if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) {
l++;
didStartWord = true;
} else {
if (didStartWord) {
didStartWord = false;
nw++;
}
}
}
if (didStartWord) {
nw++;
}
fout << l / nw;
return 0;
}