Pagini recente » Cod sursa (job #1733015) | Cod sursa (job #315359) | Istoria paginii utilizator/anna_bozianu | Monitorul de evaluare | Cod sursa (job #1210717)
/*******************************************************************************************
* .--. *
* ::\`--._,'.::.`._.--'/:: @author Ana M. Mihut @course InfoArena Tryout *
* ::::. ` __::__ ' .::::: @alias LT-Kerrigan @date 19.07.2014 *
* ::::::-:.`'..`'.:-:::::: @link http://infoarena.ro/problema/text *
* ::::::::\ `--' /:::::::: @detail "Use regex" they said "It'll be fun" they said *
* *
********************************************************************************************/
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <sstream>
#include <string>
#include <string.h>
using namespace std;
bool is_letter(char c) { return c >= 65 && c <= 90 || c >= 97 && c <= 122; }
int count_words(const string& s) {
int i = 0, N = s.size(), count = 0, letterCount = 0;
while (i < N) {
while (i < N && !is_letter(s[i])) i++;
if (i == N) break;
while (i < N && is_letter(s[i])) {
i++;
letterCount++;
}
count++;
}
//printf("%d\n", letterCount);
//return count;
return letterCount / count;
}
int main(){
freopen("text.in", "r", stdin);
freopen("text.out", "w", stdout);
std::ifstream file("text.in");
std::string s;
std::getline(file, s);
printf("%d\n", count_words(s));
return 0;
}