Pagini recente » Cod sursa (job #825941) | Cod sursa (job #569636) | Cod sursa (job #1005628) | Cod sursa (job #1782437) | Cod sursa (job #1395146)
#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;
}