Pagini recente » Cod sursa (job #2572370) | Cod sursa (job #1600822) | Cod sursa (job #2086539) | Cod sursa (job #913265) | Cod sursa (job #1332668)
#include <iostream>
#include <fstream>
#include <cstring>
using namespace std;
ifstream fin ("text.in");
ofstream fout ("text.out");
string s;
int main(){
int total=0, words=1;
bool ok;
getline (fin, s);
if((s[0]>='a' && s[0]<='z') || (s[0]>='A' && s[0]<='Z')) total++;
for(int i=1; i<s.size(); i++){
if((s[i]>='a' && s[i]<='z') || (s[i]>='A' && s[i]<='Z'))
total++, ok=true;
else if(ok && ((s[i-1]>='a' && s[i]<='z') || (s[i]>='A' && s[i]<='Z')))
words++, ok=false;
}
fout << total/words;
return 0;
}