Pagini recente » Cod sursa (job #2931354) | Cod sursa (job #3224330) | Cod sursa (job #1158396) | Cod sursa (job #14930) | Cod sursa (job #3153779)
#include <fstream>
#include <string>
using namespace std;
ifstream fin("text.in");
ofstream fout("text.out");
bool litera(char i){
return (i >= 'A' && i <= 'Z') || (i >= 'a' && i <= 'z');
}
int main(){
string str;
int litere = 0;
int cuvinte = 0;
int pozitie = 0;
while (fin >> str) {
pozitie = 0;
while (pozitie < str.size()) {
if (pozitie > 0 && litera(str[pozitie - 1]) && !litera(str[pozitie])) {
cuvinte++;
}
while (pozitie < str.size() && !litera(str[pozitie])) {
pozitie++;
}
while (pozitie < str.size() && litera(str[pozitie])) {
litere++;
pozitie++;
}
}
if (litera(str[str.size() - 1]))
cuvinte++;
}
if (cuvinte == 0) {
fout << 0;
} else {
fout << litere / cuvinte;
}
return 0;
}