Pagini recente » Cod sursa (job #1842085) | Cod sursa (job #2834031) | Cod sursa (job #867028) | Cod sursa (job #2593749) | Cod sursa (job #1334376)
#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=0;
bool ok;
s+=' ';
while(!fin.eof()){
getline (fin, s);
for(int i=0; i<s.size(); i++){
if(isalpha(s[i])) total++, ok= true;
if(i==s.size()) break;
if(!isalpha(s[i+1]) && ok) words++, ok= false;
}
}
if(words==0) return 0;
fout << total/words;
return 0;
}