Cod sursa(job #1550514)
| Utilizator | Data | 13 decembrie 2015 20:21:57 | |
|---|---|---|---|
| Problema | Text | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.58 kb |
#include <fstream>
#include <string>
inline bool isAlpha(char c)
{
return ('a'<=c&&c<='z') ||('A'<=c&&c<='Z');
}
int main()
{
std::ifstream in("text.in");
std::ofstream out("text.out");
char c;
long n_alphas = 0, n_words = 0, ctr=0;
bool prev_alpha = false;
while(in.get(c)) {
++ctr;
if(isAlpha(c)) {
if(!prev_alpha) {
++n_words;
}
prev_alpha = true;
++n_alphas;
}
else {
prev_alpha = false;
}
}
out<<n_alphas/n_words<<'\n';
return 0;
}
